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}\""))!;
|
var max = (int)(await ScalarAsync(pg, $"SELECT COALESCE(MAX(\"{pkName}\"), 0) FROM \"{table}\""))!;
|
||||||
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.
|
||||||
// %I quotes each identifier so pg_get_serial_sequence keeps the
|
// pg_get_serial_sequence takes one regclass; %I keeps the exact case EF
|
||||||
// exact case EF created the table/column with (unquoted literals
|
// used (unquoted literals fold to lowercase -> 42P01)
|
||||||
// get folded to lowercase -> 42P01 "relation does not exist")
|
|
||||||
await target.Database.ExecuteSqlRawAsync(
|
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}");
|
Console.WriteLine($"\n[done ] {table}: copied={copied}, maxId={max}");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user