fix(datacopy): pg_get_serial_sequence takes 1 arg (regclass), not table+column
This commit is contained in:
@@ -168,12 +168,11 @@ internal static class Program
|
||||
var max = (int)(await ScalarAsync(pg, $"SELECT COALESCE(MAX(\"{pkName}\"), 0) FROM \"{table}\""))!;
|
||||
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")
|
||||
// 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)
|
||||
await target.Database.ExecuteSqlRawAsync(
|
||||
$"SELECT setval(pg_get_serial_sequence(format('%I.%I', '{table}', '{pkName}')), {max})");
|
||||
$"SELECT setval(pg_get_serial_sequence(format('%I', '{table}')), {max})");
|
||||
}
|
||||
Console.WriteLine($"\n[done ] {table}: copied={copied}, maxId={max}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user