fix(datacopy): use pg_get_serial_sequence(text, text) overload — verified against local PG 18

This commit is contained in:
2026-10-10 01:05:14 +03:30
parent 40516e8f23
commit 2a786acfb6

View File

@@ -169,10 +169,10 @@ internal static class Program
if (max > 0) if (max > 0)
{ {
// Keep the identity sequence above the copied max so new rows don't collide. // Keep the identity sequence above the copied max so new rows don't collide.
// pg_get_serial_sequence needs a regclass (or table+column text); %I keeps // pg_get_serial_sequence(text, text) — verified signature. format('%I', ...)
// the exact case EF used, and ::regclass resolves it unambiguously // preserves the exact table case EF used; the column is passed as plain text.
await target.Database.ExecuteSqlRawAsync( await target.Database.ExecuteSqlRawAsync(
$"SELECT setval(pg_get_serial_sequence(format('%I', '{table}')::regclass, '{pkName}'), {max})"); $"SELECT setval(pg_get_serial_sequence(format('%I', '{table}'), '{pkName}'), {max})");
} }
Console.WriteLine($"\n[done ] {table}: copied={copied}, maxId={max}"); Console.WriteLine($"\n[done ] {table}: copied={copied}, maxId={max}");
} }