43 lines
1.5 KiB
MySQL
43 lines
1.5 KiB
MySQL
|
CREATE OR REPLACE TABLE `vn`.`parkingLog` (
|
||
|
|
||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
|
|
||
|
`originFk` int(11) DEFAULT NULL,
|
||
|
|
||
|
`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('Parking','SaleGroup','SaleGroupDetail') NOT NULL DEFAULT 'Parking',
|
||
|
|
||
|
`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 `logParkinguserFk` (`userFk`),
|
||
|
|
||
|
KEY `parkingLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`),
|
||
|
|
||
|
KEY `parkingLog_originFk` (`originFk`,`creationDate`),
|
||
|
|
||
|
CONSTRAINT `parkingOriginFk` FOREIGN KEY (`originFk`) REFERENCES `parking` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||
|
|
||
|
CONSTRAINT `parkingUserFk` 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;
|
||
|
|
||
|
ALTER TABLE vn.parking DROP COLUMN IF EXISTS editorFk;
|
||
|
ALTER TABLE IF EXISTS vn.parking ADD COLUMN editorFk INT;
|
||
|
|
||
|
ALTER TABLE vn.saleGroupDetail DROP COLUMN IF EXISTS editorFk;
|
||
|
ALTER TABLE IF EXISTS vn.saleGroupDetail ADD COLUMN editorFk INT;
|