From 40516e8f231085019043b0658d81b0f9fb577be2 Mon Sep 17 00:00:00 2001 From: alireza Date: Sat, 10 Oct 2026 01:01:30 +0330 Subject: [PATCH] fix(datacopy): cast format('%I') result to regclass for pg_get_serial_sequence --- src/GreenHome.DataCopy/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GreenHome.DataCopy/Program.cs b/src/GreenHome.DataCopy/Program.cs index aa7ee17..6f3286f 100644 --- a/src/GreenHome.DataCopy/Program.cs +++ b/src/GreenHome.DataCopy/Program.cs @@ -169,10 +169,10 @@ internal static class Program if (max > 0) { // 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) + // pg_get_serial_sequence needs a regclass (or table+column text); %I keeps + // the exact case EF used, and ::regclass resolves it unambiguously 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}"); }