diff --git a/src/GreenHome.DataCopy/Program.cs b/src/GreenHome.DataCopy/Program.cs index 174ec5d..66b8c31 100644 --- a/src/GreenHome.DataCopy/Program.cs +++ b/src/GreenHome.DataCopy/Program.cs @@ -169,8 +169,11 @@ internal static class Program 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") await target.Database.ExecuteSqlRawAsync( - $"SELECT setval(pg_get_serial_sequence('{table}', '{pkName}'), {max})"); + $"SELECT setval(pg_get_serial_sequence(format('%I.%I', '{table}', '{pkName}')), {max})"); } Console.WriteLine($"\n[done ] {table}: copied={copied}, maxId={max}"); }