ALTER TABLE `vn`.`travel` ADD agencyModeFk INT DEFAULT NULL NULL; ALTER TABLE `vn`.`travel` ADD CONSTRAINT travel_FK FOREIGN KEY (agencyModeFk) REFERENCES `vn`.`agencyMode`(id) ON DELETE RESTRICT ON UPDATE CASCADE; ALTER TABLE `vn`.`travel` ADD CONSTRAINT shipment_1 UNIQUE KEY (shipped,landed,warehouseInFk,warehouseOutFk,agencyFk,agencyModeFk,`ref`); ALTER TABLE `vn`.`travel` DROP KEY shipment_2; UPDATE `vn`.`travel` SET agencyModeFk = agencyFk;