Merged in bugfix/delete-client-cascade (pull request #220)
fix cascading delete issue * test passing
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
-- Revert to original FK constraints (NO ACTION).
|
||||
|
||||
ALTER TABLE batch_document_outcomes
|
||||
DROP CONSTRAINT fk_batch_doc_outcomes_document_id;
|
||||
|
||||
ALTER TABLE batch_document_outcomes
|
||||
DROP CONSTRAINT fk_batch_doc_outcomes_batch_id;
|
||||
|
||||
ALTER TABLE batch_document_outcomes
|
||||
ADD CONSTRAINT batch_document_outcomes_document_id_fkey
|
||||
FOREIGN KEY (document_id) REFERENCES documents(id);
|
||||
|
||||
ALTER TABLE batch_document_outcomes
|
||||
ADD CONSTRAINT batch_document_outcomes_batch_id_fkey
|
||||
FOREIGN KEY (batch_id) REFERENCES batch_uploads(id);
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
-- Fix batch_document_outcomes FK constraints to support cascading deletes.
|
||||
-- document_id: SET NULL preserves batch outcome history when a document is hard-deleted.
|
||||
-- batch_id: CASCADE removes outcome rows when their owning batch_upload is deleted.
|
||||
|
||||
ALTER TABLE batch_document_outcomes
|
||||
DROP CONSTRAINT batch_document_outcomes_document_id_fkey;
|
||||
|
||||
ALTER TABLE batch_document_outcomes
|
||||
DROP CONSTRAINT batch_document_outcomes_batch_id_fkey;
|
||||
|
||||
ALTER TABLE batch_document_outcomes
|
||||
ADD CONSTRAINT fk_batch_doc_outcomes_document_id
|
||||
FOREIGN KEY (document_id) REFERENCES documents(id) ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE batch_document_outcomes
|
||||
ADD CONSTRAINT fk_batch_doc_outcomes_batch_id
|
||||
FOREIGN KEY (batch_id) REFERENCES batch_uploads(id) ON DELETE CASCADE;
|
||||
Reference in New Issue
Block a user