29 lines
2.4 KiB
MySQL
29 lines
2.4 KiB
MySQL
|
ALTER TABLE vn.deviceProduction ADD editorFk int(10) unsigned NULL;
|
||
|
ALTER TABLE vn.deviceProductionModels ADD editorFk int(10) unsigned NULL;
|
||
|
ALTER TABLE vn.deviceProductionState ADD editorFk int(10) unsigned NULL;
|
||
|
ALTER TABLE vn.deviceProductionUser ADD editorFk int(10) unsigned NULL;
|
||
|
ALTER TABLE vn.deviceProduction ADD CONSTRAINT deviceProduction_fk_editor FOREIGN KEY (editorFk) REFERENCES account.`user`(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||
|
ALTER TABLE vn.deviceProductionModels ADD CONSTRAINT deviceProductionModels_fk_editor FOREIGN KEY (editorFk) REFERENCES account.`user`(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||
|
ALTER TABLE vn.deviceProductionState ADD CONSTRAINT deviceProductionState_fk_editor FOREIGN KEY (editorFk) REFERENCES account.`user`(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||
|
ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_fk_editor FOREIGN KEY (editorFk) REFERENCES account.`user`(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||
|
|
||
|
DROP TABLE vn.deviceProductionLog;
|
||
|
CREATE TABLE `vn`.`deviceProductionLog` (
|
||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
|
`originFk` int(11) DEFAULT NULL,
|
||
|
`userFk` int(10) unsigned DEFAULT NULL,
|
||
|
`action` set('insert','update','delete') NOT NULL,
|
||
|
`creationDate` timestamp NULL DEFAULT current_timestamp(),
|
||
|
`description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
|
||
|
`changedModel` enum('DeviceProduction','DeviceProductionModels','DeviceProductionState','DeviceProductionUser') NOT NULL DEFAULT 'DeviceProduction',
|
||
|
`oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)),
|
||
|
`newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)),
|
||
|
`changedModelId` int(11) NOT NULL,
|
||
|
`changedModelValue` varchar(45) DEFAULT NULL,
|
||
|
PRIMARY KEY (`id`),
|
||
|
KEY `userFk` (`userFk`),
|
||
|
KEY `deviceProductionLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`),
|
||
|
KEY `deviceProductionLog_deviceProductionLog` (`originFk`,`creationDate`),
|
||
|
CONSTRAINT `deviceProductionOriginFk` FOREIGN KEY (`originFk`) REFERENCES `deviceProduction` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||
|
CONSTRAINT `deviceProductionUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||
|
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1;
|