From 5cd80dbf34c9467a672110589c5cf46efc9d98ff Mon Sep 17 00:00:00 2001 From: alireza Date: Sat, 10 Oct 2026 00:56:04 +0330 Subject: [PATCH] fix(datacopy): quote identifiers in pg_get_serial_sequence via format('%I.%I') --- src/GreenHome.DataCopy/Program.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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}"); }