salix/db/versions/.archive/10144-silverAralia/00-AfegirFKPArt1.sql

63 lines
3.6 KiB
SQL

-- vn mail recipientFk
ALTER TABLE vn.mail MODIFY COLUMN recipientFk int(10) unsigned NULL;
ALTER TABLE vn.mail ADD CONSTRAINT mail_FK_1 FOREIGN KEY (recipientFk) REFERENCES account.user(id) ON UPDATE CASCADE;
-- vn mail senderFk
ALTER TABLE vn.mail MODIFY COLUMN senderFk int(10) unsigned NULL;
ALTER TABLE vn.mail ADD CONSTRAINT mail_FK FOREIGN KEY (senderFk) REFERENCES account.user(id) ON UPDATE CASCADE;
-- vn packaging packagingReturnFk
ALTER TABLE vn.packaging ADD CONSTRAINT packaging_FK_1 FOREIGN KEY (packagingReturnFk) REFERENCES vn2008.Cubos_Retorno(idCubos_Retorno) ON UPDATE CASCADE;
-- vn printServerQueue2
ALTER TABLE vn.printServerQueue2 ADD CONSTRAINT printServerQueue2_FK_1 FOREIGN KEY (printerFk) REFERENCES vn.printer(id);
ALTER TABLE vn.printServerQueue2 ADD CONSTRAINT printServerQueue2_FK_2 FOREIGN KEY (priorityFk) REFERENCES vn.queuePriority(id);
-- vn recipe inkFk
ALTER TABLE vn.recipe ADD CONSTRAINT recipe_FK FOREIGN KEY (inkFk) REFERENCES vn.ink(id) ON UPDATE CASCADE;
-- vn recipe_log recipe_ItemFk
ALTER TABLE vn.recipe_log ADD CONSTRAINT recipe_log_FK FOREIGN KEY (recipe_ItemFk) REFERENCES vn.item(id) ON UPDATE CASCADE;
-- vn recipe_log selected_ItemFk
ALTER TABLE vn.recipe_log ADD CONSTRAINT recipe_log_FK_1 FOREIGN KEY (selected_ItemFk) REFERENCES vn.item(id) ON UPDATE CASCADE;
-- vn routesMonitor dockFk
ALTER TABLE vn.routesMonitor MODIFY COLUMN dockFk varchar(10) NULL;
ALTER TABLE vn.routesMonitor ADD CONSTRAINT routesMonitor_FK_1 FOREIGN KEY (dockFk) REFERENCES vn.dock(code) ON UPDATE CASCADE;
-- vn saleTracking actionFk
ALTER TABLE vn.saleTracking MODIFY COLUMN actionFk int(11) NULL;
UPDATE vn.saleTracking SET actionFk = NULL WHERE actionFk = 0;
ALTER TABLE vn.saleTracking ADD CONSTRAINT saleTracking_FK_1 FOREIGN KEY (actionFk) REFERENCES vncontrol.accion(accion_id) ON UPDATE CASCADE;
-- vn sector sonFk
ALTER TABLE vn.sector ADD CONSTRAINT sector_FK FOREIGN KEY (sonFk,warehouseFk) REFERENCES vn.sector(id,warehouseFk) ON UPDATE CASCADE;
-- vn sms senderFk
ALTER TABLE vn.sms MODIFY COLUMN senderFk int(10) unsigned NOT NULL;
ALTER TABLE vn.sms ADD CONSTRAINT sms_FK FOREIGN KEY (senderFk) REFERENCES account.`user`(id) ON UPDATE CASCADE;
-- vn state nextStateFk
ALTER TABLE vn.state MODIFY COLUMN nextStateFk tinyint(3) unsigned NOT NULL COMMENT 'Estado al que tiene que cambiar el ticket despues de preparacion previa';
ALTER TABLE vn.state ADD CONSTRAINT state_FK FOREIGN KEY (nextStateFk) REFERENCES vn.state(id) ON UPDATE CASCADE;
-- vn supplierAccount bankEntityFk
ALTER TABLE vn.supplierAccount MODIFY COLUMN bankEntityFk int(10) unsigned NULL;
ALTER TABLE vn.supplierAccount ADD CONSTRAINT supplierAccount_FK_1 FOREIGN KEY (bankEntityFk) REFERENCES vn.bankEntity(id) ON UPDATE CASCADE;
-- suplier
ALTER TABLE vn.supplierAccount MODIFY COLUMN supplierFk int(11) NULL;
UPDATE vn.supplierAccount SET supplierFk = null WHERE supplierFk NOT IN (SELECT id FROM vn.supplier s);
ALTER TABLE vn.supplierAccount ADD CONSTRAINT supplierAccount_FK FOREIGN KEY (supplierFk) REFERENCES vn.supplier(id) ON UPDATE CASCADE;
-- vn ticketCollection smartTagFk
ALTER TABLE vn.ticketCollection MODIFY COLUMN smartTagFk varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NULL;
ALTER TABLE vn.ticketCollection ADD CONSTRAINT ticketCollection_FK FOREIGN KEY (smartTagFk) REFERENCES vn.smartTag(code) ON UPDATE CASCADE;
-- vn workCenter payrollCenterFk
ALTER TABLE vn.workCenter MODIFY COLUMN payrollCenterFk int(11) NULL COMMENT 'Campo workcenter en A3';
-- vn warehouse pickUpAgencyModeFk
ALTER TABLE vn.warehouse ADD CONSTRAINT warehouse_FK_1 FOREIGN KEY (pickUpAgencyModeFk) REFERENCES vn.agencyMode(id) ON UPDATE CASCADE;