fix(datacopy): cast format('%I') result to regclass for pg_get_serial_sequence

This commit is contained in:
2026-10-10 01:01:30 +03:30
parent f58c14511b
commit 40516e8f23

View File

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