FIX(BE): update foreign key constraints to use ON DELETE NO ACTION for expense and marketing tables

This commit is contained in:
aguhh18
2026-01-06 12:43:52 +07:00
parent d8fb427734
commit a08466a28e
4 changed files with 86 additions and 0 deletions
@@ -0,0 +1,15 @@
-- Revert back to NO ACTION (RESTRICT behavior)
ALTER TABLE expense_nonstocks DROP CONSTRAINT IF EXISTS fk_expense_nonstocks_expense_id;
ALTER TABLE expense_nonstocks
ADD CONSTRAINT fk_expense_nonstocks_expense_id
FOREIGN KEY (expense_id) REFERENCES expenses(id)
ON DELETE NO ACTION;
-- Revert expense_realizations FK
ALTER TABLE expense_realizations DROP CONSTRAINT IF EXISTS fk_expense_realizations_nonstock_id;
ALTER TABLE expense_realizations
ADD CONSTRAINT fk_expense_realizations_nonstock_id
FOREIGN KEY (expense_nonstock_id) REFERENCES expense_nonstocks(id)
ON DELETE NO ACTION;