fix: refs #5186 create parkingLog & add sector relation
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-02-29 14:43:37 +01:00
parent 0af17fb081
commit c54c9ce913
5 changed files with 62 additions and 5 deletions

View File

@ -0,0 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_afterDelete`
AFTER DELETE ON `parking`
FOR EACH ROW
BEGIN
INSERT INTO parkingLog
SET `action` = 'delete',
`changedModel` = 'Parking',
`changedModelId` = OLD.id,
`userFk` = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_beforeInsert`
BEFORE INSERT ON `parking`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
-- SET new.`code` = CONCAT(new.`column`,' - ',new.`row`) ;
END$$

View File

@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_beforeUpdate`
BEFORE UPDATE ON `parking`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
-- SET new.`code` = CONCAT(new.`column`,' - ',new.`row`) ;
END$$

View File

@ -0,0 +1,43 @@
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;

View File

@ -20,9 +20,6 @@
"type": "string",
"required": true
},
"sectorFk": {
"type": "number"
},
"code": {
"type": "string"
},
@ -35,6 +32,11 @@
"type": "hasMany",
"model": "saleGroup",
"foreignKey": "parkingFk"
},
"sector": {
"type": "belongsTo",
"model": "Sector",
"foreignKey": "sectorFk"
}
}
}