salix/db/versions/11269-wheatBirch/00-firstScript.sql

9 lines
453 B
MySQL
Raw Normal View History

2024-09-30 07:17:27 +00:00
ALTER TABLE vn.invoiceOut ADD COLUMN IF NOT EXISTS customsAgentFk INT(11) DEFAULT NULL AFTER siiTrascendencyInvoiceOutFk;
ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_customsAgentFk FOREIGN KEY (customsAgentFk)
REFERENCES vn.customsAgent (id) ON DELETE RESTRICT ON UPDATE CASCADE;
UPDATE vn.invoiceOut i
JOIN vn.client c ON c.id = io.clientFk
JOIN vn.address a ON a.id = c.defaultAddressFk
SET i.customsAgentFk = a.customsAgentFk;