-- Drop existing FK constraints
ALTER TABLE expense_nonstocks DROP CONSTRAINT IF EXISTS fk_expense_nonstocks_expense_id;

-- Recreate with ON DELETE CASCADE
ALTER TABLE expense_nonstocks
    ADD CONSTRAINT fk_expense_nonstocks_expense_id
    FOREIGN KEY (expense_id) REFERENCES expenses(id)
    ON DELETE CASCADE;

-- Drop and recreate 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 CASCADE;
