Merge pull request '#6513 delete wrong records' (!2099) from 6513-deleteWrongRecords into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #2099
Reviewed-by: Guillermo Bonet <guillermo@verdnatura.es>
Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
This commit is contained in:
Jorge Penadés 2024-02-27 09:19:39 +00:00
commit ab2b0ec519
1 changed files with 18 additions and 2 deletions

View File

@ -1,9 +1,25 @@
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
);
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),
ADD CONSTRAINT dms_FK FOREIGN KEY (dmsFk) REFERENCES vn.dms(id) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT dms_Fk FOREIGN KEY (dmsFk) REFERENCES vn.dms(id) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT supplier_Fk FOREIGN KEY (supplierFk) REFERENCES vn.supplier(id) ON UPDATE CASCADE;
ALTER TABLE `supplierLog`
ALTER TABLE `vn`.`supplierLog`
MODIFY COLUMN `changedModel` ENUM('Supplier','SupplierAddress','SupplierAccount','SupplierContact','SupplierDms') NOT NULL DEFAULT 'Supplier';