salix/db/versions/.archive/10384-limeLaurel/00-business_workcenterFk.sql

16 lines
447 B
SQL

ALTER TABLE `vn`.`business` MODIFY COLUMN workcenterFk int(11) NULL;
UPDATE `vn`.`business` b
SET b.workcenterFk = NULL
WHERE b.workcenterFk = 0;
ALTER TABLE `vn`.`business`
ADD INDEX IF NOT EXISTS `business_workcenterFk_idx` (`workcenterFk` ASC);
ALTER TABLE `vn`.`business`
ADD CONSTRAINT `business_workcenterFk`
FOREIGN KEY IF NOT EXISTS (`workcenterFk`)
REFERENCES `vn`.`workCenter` (`id`)
ON DELETE RESTRICT
ON UPDATE CASCADE;