fix(datacopy): quote identifiers in pg_get_serial_sequence via format('%I.%I')

This commit is contained in:
2026-10-10 00:56:04 +03:30
parent 923b6b325b
commit 5cd80dbf34

View File

@@ -169,8 +169,11 @@ internal static class Program
if (max > 0)
{
// Keep the identity sequence above the copied max so new rows don't collide
// %I quotes each identifier so pg_get_serial_sequence keeps the
// exact case EF created the table/column with (unquoted literals
// get folded to lowercase -> 42P01 "relation does not exist")
await target.Database.ExecuteSqlRawAsync(
$"SELECT setval(pg_get_serial_sequence('{table}', '{pkName}'), {max})");
$"SELECT setval(pg_get_serial_sequence(format('%I.%I', '{table}', '{pkName}')), {max})");
}
Console.WriteLine($"\n[done ] {table}: copied={copied}, maxId={max}");
}