You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that, when the foreign keys are added back, the constraints are missing the ON UPDATE and ON DELETE triggers/events.
From the code below that seems to be the case. However, I do see some FK constraints with the triggers. I'm assuming these are copied over somehow though and not actually generated.
Here is a pure SQL way to build out the ALTER statements for restoring the constraints. You can build the drops, similarly:
DROP
SELECT'ALTER TABLE "'||nspname||'"."'||relname||'" DROP CONSTRAINT "'||conname||'";'FROM pg_constraint
INNER JOIN pg_class ON conrelid=pg_class.oidINNER JOIN pg_namespace ONpg_namespace.oid=pg_class.relnamespaceORDER BY CASE WHEN contype='f' THEN 0 ELSE 1 END,contype,nspname,relname,conname;
ADD
SELECT'ALTER TABLE "'||nspname||'"."'||relname||'" ADD CONSTRAINT "'||conname||'" '|| pg_get_constraintdef(pg_constraint.oid)||';'FROM pg_constraint
INNER JOIN pg_class ON conrelid=pg_class.oidINNER JOIN pg_namespace ONpg_namespace.oid=pg_class.relnamespaceORDER BY CASE WHEN contype='f' THEN 0 ELSE 1 END DESC,contype DESC,nspname DESC,relname DESC,conname DESC;
It appears that, when the foreign keys are added back, the constraints are missing the
ON UPDATE
andON DELETE
triggers/events.From the code below that seems to be the case. However, I do see some FK constraints with the triggers. I'm assuming these are copied over somehow though and not actually generated.
The text was updated successfully, but these errors were encountered: