salix/db/versions/10908-blueAsparagus/00-createSupplierDms.sql

25 lines
907 B
MySQL
Raw Permalink Normal View History

2024-02-26 14:11:02 +00:00
DELETE FROM vn.supplierDms
WHERE dmsFk IN (
SELECT sd.dmsFk
FROM vn.supplierDms sd
LEFT JOIN vn.dms d ON d.id = sd.dmsFk
WHERE d.id IS NULL
);
DELETE FROM vn.supplierDms
WHERE supplierFk IN (
SELECT sd.supplierFk
FROM vn.supplierDms sd
LEFT JOIN vn.supplier s ON s.id = sd.supplierFk
WHERE s.id IS NULL
);
2024-02-26 08:35:06 +00:00
ALTER TABLE `vn`.`supplierDms`
MODIFY COLUMN supplierFk int(10) unsigned NOT NULL,
ADD editorFk INT UNSIGNED NULL,
ADD CONSTRAINT user_Fk FOREIGN KEY (editorFk) REFERENCES account.`user`(id),
2024-02-26 14:11:02 +00:00
ADD CONSTRAINT dms_Fk FOREIGN KEY (dmsFk) REFERENCES vn.dms(id) ON DELETE CASCADE ON UPDATE CASCADE,
2024-02-26 08:35:06 +00:00
ADD CONSTRAINT supplier_Fk FOREIGN KEY (supplierFk) REFERENCES vn.supplier(id) ON UPDATE CASCADE;
2024-02-23 15:27:49 +00:00
2024-02-27 07:50:23 +00:00
ALTER TABLE `vn`.`supplierLog`
2024-02-26 08:35:06 +00:00
MODIFY COLUMN `changedModel` ENUM('Supplier','SupplierAddress','SupplierAccount','SupplierContact','SupplierDms') NOT NULL DEFAULT 'Supplier';