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

15 lines
810 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 COLUMN IF NOT EXISTS incotermsFk varchar(3) DEFAULT NULL AFTER customsAgentFk;
2024-09-30 07:17:27 +00:00
ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_customsAgentFk FOREIGN KEY (customsAgentFk)
REFERENCES vn.customsAgent (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_incotermsFk FOREIGN KEY (incotermsFk)
REFERENCES vn.incoterms (`code`) ON DELETE RESTRICT ON UPDATE CASCADE;
2024-09-30 07:21:05 +00:00
UPDATE vn.invoiceOut io
JOIN vn.client c ON c.id = io.clientFk
JOIN vn.ticket t ON t.clientFk = c.id
JOIN vn.address a ON a.id = t.addressFk
SET io.customsAgentFk = a.customsAgentFk,
io.incotermsFk = a.incotermsFk;