19 lines
1011 B
MySQL
19 lines
1011 B
MySQL
|
CREATE TABLE IF NOT EXISTS `agencyWorkCenter` (
|
||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||
|
`agencyFk` smallint(5) unsigned NOT NULL,
|
||
|
`workCenterFk` int(11) NOT NULL,
|
||
|
`editorFk` int(10) unsigned DEFAULT NULL,
|
||
|
PRIMARY KEY (`id`),
|
||
|
UNIQUE KEY `agencyWorkCenter_unique` (`agencyFk`,`workCenterFk`),
|
||
|
KEY `agencyWorkCenter_workCenter_FK` (`workCenterFk`),
|
||
|
KEY `agencyWorkCenter_user_FK` (`editorFk`),
|
||
|
CONSTRAINT `agencyWorkCenter_agency_FK` FOREIGN KEY (`agencyFk`) REFERENCES `agency` (`id`) ON DELETE CASCADE,
|
||
|
CONSTRAINT `agencyWorkCenter_user_FK` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||
|
CONSTRAINT `agencyWorkCenter_workCenter_FK` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`)
|
||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #4988';
|
||
|
|
||
|
INSERT INTO vn.agencyWorkCenter (agencyFk, workCenterFk)
|
||
|
SELECT id, workCenterFk
|
||
|
FROM vn.agency
|
||
|
WHERE workCenterFk IS NOT NULL;
|