pgadmin4 icon indicating copy to clipboard operation
pgadmin4 copied to clipboard

Schema Diff ignores a change to INITIALLY DEFERRED on primary key and unique constraints

Open arvindkumar-ship-it opened this issue 2 weeks ago • 0 comments

In table_constraint_comp() (schema_diff_table_utils.py), the non-editable keys for primary_key and unique_constraint list 'condeffered', but the index constraint properties query returns condeferred. The key never matches, so a constraint whose INITIALLY DEFERRED state differs goes to "changed" instead of being dropped and recreated. The index constraint update template has no DEFERRABLE clause, so the generated script leaves the target's deferred state as it is.

To reproduce: create the same table in two databases, with PRIMARY KEY (id) DEFERRABLE INITIALLY DEFERRED in the source and PRIMARY KEY (id) DEFERRABLE INITIALLY IMMEDIATE in the target, and compare them with Schema Diff. The table is reported as different, but the script does not change the constraint.

Found by CodeRabbit during the review of #10782.

arvindkumar-ship-it avatar Nov 16 '26 13:11 arvindkumar-ship-it