fix(datacopy): cast format('%I') result to regclass for pg_get_serial_sequence
This commit is contained in:
@@ -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 takes one regclass; %I keeps the exact case EF
|
// pg_get_serial_sequence needs a regclass (or table+column text); %I keeps
|
||||||
// used (unquoted literals fold to lowercase -> 42P01)
|
// the exact case EF used, and ::regclass resolves it unambiguously
|
||||||
await target.Database.ExecuteSqlRawAsync(
|
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}");
|
Console.WriteLine($"\n[done ] {table}: copied={copied}, maxId={max}");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user