From 336c3274ea40cb9c536b157684b0608b8bcfa5ab Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Apr 2024 07:38:48 +0200 Subject: [PATCH] feat(agency): refs #4988 add summary --- back/models/agency-log.json | 9 ++++++++ .../vn/triggers/agency_afterInsert.sql | 1 + .../10995-navyErica/00-firstScript.sql | 2 ++ .../10995-navyErica/01-agencyLogCreate.sql | 23 +++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 back/models/agency-log.json create mode 100644 db/versions/10995-navyErica/00-firstScript.sql create mode 100644 db/versions/10995-navyErica/01-agencyLogCreate.sql diff --git a/back/models/agency-log.json b/back/models/agency-log.json new file mode 100644 index 000000000..04b0b2995 --- /dev/null +++ b/back/models/agency-log.json @@ -0,0 +1,9 @@ +{ + "name": "AgencyLog", + "base": "Log", + "options": { + "mysql": { + "table": "agencyLog" + } + } +} diff --git a/db/routines/vn/triggers/agency_afterInsert.sql b/db/routines/vn/triggers/agency_afterInsert.sql index 35670538b..cdd6401cd 100644 --- a/db/routines/vn/triggers/agency_afterInsert.sql +++ b/db/routines/vn/triggers/agency_afterInsert.sql @@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`agency_afterInsert` AFTER INSERT ON `agency` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); INSERT INTO agencyMode(name,agencyFk) VALUES(NEW.name,NEW.id); END$$ DELIMITER ; diff --git a/db/versions/10995-navyErica/00-firstScript.sql b/db/versions/10995-navyErica/00-firstScript.sql new file mode 100644 index 000000000..15fcaeef6 --- /dev/null +++ b/db/versions/10995-navyErica/00-firstScript.sql @@ -0,0 +1,2 @@ +-- Place your SQL code here +INSERT INTO salix.ACL (id, model, property, accessType, permission, principalType, principalId) VALUES(826, 'Agency', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/versions/10995-navyErica/01-agencyLogCreate.sql b/db/versions/10995-navyErica/01-agencyLogCreate.sql new file mode 100644 index 000000000..ec0ae0bdd --- /dev/null +++ b/db/versions/10995-navyErica/01-agencyLogCreate.sql @@ -0,0 +1,23 @@ +-- vn.agencyLog definition +ALTER TABLE vn.agency ADD IF NOT EXISTS editorFk int(10) unsigned DEFAULT NULL NULL; + + +CREATE TABLE IF NOT EXISTS `agencyLog` ( + `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('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`), + CONSTRAINT `agencyOriginFk` FOREIGN KEY (`agency`) REFERENCES `agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `agencyUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file