diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 6645b9cb2..613139fc7 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -28,6 +28,10 @@ BEGIN DELETE FROM ticketDown WHERE created < util.yesterday(); DELETE FROM entryLog WHERE creationDate < v2Months; DELETE IGNORE FROM expedition WHERE created < v26Months; + DELETE cs.* + FROM sms s + JOIN clientSms cs ON cs.smsFk = s.id + WHERE s. created < v18Months; DELETE FROM sms WHERE created < v18Months; DELETE FROM saleTracking WHERE created < v1Years; DELETE FROM productionError WHERE dated < v1Years; diff --git a/db/versions/11152-goldenRaphis/00-firstScript.sql b/db/versions/11152-goldenRaphis/00-firstScript.sql new file mode 100644 index 000000000..ad58a570a --- /dev/null +++ b/db/versions/11152-goldenRaphis/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.ticketSms__ DROP FOREIGN KEY IF EXISTS ticketSms_FK; +ALTER TABLE vn.ticketSms__ ADD CONSTRAINT ticketSms_FK FOREIGN KEY (smsFk) REFERENCES vn.sms(id) ON DELETE CASCADE ON UPDATE CASCADE;