From d0dfdc668b313dea77ba828947f8d43f21659c90 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Apr 2024 16:25:27 +0200 Subject: [PATCH] feat(agency): refs #4988 add new agency --- back/model-config.json | 3 +++ db/routines/vn/triggers/agency_afterInsert.sql | 1 - db/routines/vn/triggers/agency_beforeInsert.sql | 8 ++++++++ db/versions/10995-navyErica/00-firstScript.sql | 5 ++++- db/versions/10995-navyErica/01-agencyLogCreate.sql | 10 +++++----- 5 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 db/routines/vn/triggers/agency_beforeInsert.sql diff --git a/back/model-config.json b/back/model-config.json index ebcdb7bce..739a7965a 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -177,5 +177,8 @@ }, "ProductionConfig": { "dataSource": "vn" + }, + "AgencyLog": { + "dataSource": "vn" } } \ No newline at end of file diff --git a/db/routines/vn/triggers/agency_afterInsert.sql b/db/routines/vn/triggers/agency_afterInsert.sql index cdd6401cd..35670538b 100644 --- a/db/routines/vn/triggers/agency_afterInsert.sql +++ b/db/routines/vn/triggers/agency_afterInsert.sql @@ -3,7 +3,6 @@ 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/routines/vn/triggers/agency_beforeInsert.sql b/db/routines/vn/triggers/agency_beforeInsert.sql new file mode 100644 index 000000000..8ff3958e1 --- /dev/null +++ b/db/routines/vn/triggers/agency_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`agency_beforeInsert` + BEFORE INSERT ON `agency` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/versions/10995-navyErica/00-firstScript.sql b/db/versions/10995-navyErica/00-firstScript.sql index 15fcaeef6..104d1c322 100644 --- a/db/versions/10995-navyErica/00-firstScript.sql +++ b/db/versions/10995-navyErica/00-firstScript.sql @@ -1,2 +1,5 @@ -- 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 +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES('Agency', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('AgencyLog','*','READ','ALLOW','ROLE','employee'); diff --git a/db/versions/10995-navyErica/01-agencyLogCreate.sql b/db/versions/10995-navyErica/01-agencyLogCreate.sql index ec0ae0bdd..bfb1f83a8 100644 --- a/db/versions/10995-navyErica/01-agencyLogCreate.sql +++ b/db/versions/10995-navyErica/01-agencyLogCreate.sql @@ -2,9 +2,9 @@ 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, +CREATE TABLE IF NOT EXISTS `vn`.`agencyLog` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `originFk` smallint(5) unsigned DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete','select') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), @@ -18,6 +18,6 @@ CREATE TABLE IF NOT EXISTS `agencyLog` ( 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 `agencyOriginFk` FOREIGN KEY (`originFk`) 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 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file