2024-04-16 05:38:48 +00:00
|
|
|
-- vn.agencyLog definition
|
|
|
|
ALTER TABLE vn.agency ADD IF NOT EXISTS editorFk int(10) unsigned DEFAULT NULL NULL;
|
|
|
|
|
2024-04-22 15:17:17 +00:00
|
|
|
ALTER TABLE vn.agency ADD CONSTRAINT agency_user_FK FOREIGN KEY (editorFk) REFERENCES `account`.`user`(id);
|
2024-04-16 05:38:48 +00:00
|
|
|
|
2024-04-16 14:25:27 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS `vn`.`agencyLog` (
|
|
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
|
|
`originFk` smallint(5) unsigned DEFAULT NULL,
|
2024-04-16 05:38:48 +00:00
|
|
|
`userFk` int(10) unsigned DEFAULT NULL,
|
|
|
|
`action` set('insert','update','delete','select') NOT NULL,
|
|
|
|
`creationDate` timestamp NULL DEFAULT current_timestamp(),
|
|
|
|
`description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
|
|
|
|
`changedModel` enum('agency','agencyMode') NOT NULL DEFAULT 'agency',
|
|
|
|
`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 `logAgencyUserFk` (`userFk`),
|
|
|
|
KEY `agencyLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`),
|
|
|
|
KEY `agencyLog_originFk` (`originFk`,`creationDate`),
|
2024-04-16 14:25:27 +00:00
|
|
|
CONSTRAINT `agencyOriginFk` FOREIGN KEY (`originFk`) REFERENCES `agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
2024-04-16 05:38:48 +00:00
|
|
|
CONSTRAINT `agencyUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
2024-04-16 14:25:27 +00:00
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|