BEGIN; ALTER TABLE person ADD CONSTRAINT person_pk PRIMARY KEY (entity_id); alter table person drop constraint person_entity_id_key CASCADE; alter table phone add CONSTRAINT phone_fk FOREIGN KEY (person_entity_id) REFERENCES person(entity_id); alter table address add CONSTRAINT address_fk FOREIGN KEY (person_id) REFERENCES person(entity_id); COMMIT;
Yea, I was hoping to avoid having to manually add the FK's to the referencing tables (34).
Is there really no way to accomplish this without DROP CONSTRAINT ... CASCADE, hacking the system-catalogs or something?
You may write a script to output those 34 FK constraints. Definitely safer than hacking pg_constraint.conindid
Yes.
I'd still argue that what I'm trying to do should "just work" as PG treats UNIQUE CONSTRAINT and UNIQUE INDEX the same wrt. the planner and FK-enforcement.