results icon indicating copy to clipboard operation
results copied to clipboard

NOT VALID is duplicated in constraints

Open davenquinn opened this issue 1 month ago • 0 comments

If a new foreign key constraint is marked NOT VALID on initial creation, the NOT VALID statement is doubled and validation is still attempted.

ALTER TABLE "macrostrat"."unit_boundaries" ADD
CONSTRAINT "unit_boundaries_unit_id_fkey"
FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id)
    ON DELETE CASCADE NOT VALID NOT VALID;

ALTER TABLE "macrostrat"."unit_boundaries" VALIDATE
CONSTRAINT "unit_boundaries_unit_id_fkey";

Once the constraint actually exists in a NOT VALID state, validation is not re-attempted on each schema diff, which means that this problem is pretty minor.

davenquinn avatar Jan 05 '26 17:01 davenquinn