From 78a9b788bf3d77ca736694d4f3fadc259cde69e7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 14 Oct 2024 08:42:54 +0200 Subject: [PATCH 1/4] feat: refs #7006 itemTypeLog created --- .../vn/triggers/itemType_afterDelete.sql | 12 ++++++++++ .../vn/triggers/itemType_beforeInsert.sql | 8 +++++++ .../vn/triggers/itemType_beforeUpdate.sql | 1 + .../triggers/productionConfig_afterDelete.sql | 2 +- .../11297-graySalal/00-firstScript.sql | 24 +++++++++++++++++++ modules/item/back/models/item-type-log.json | 9 +++++++ 6 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 db/routines/vn/triggers/itemType_afterDelete.sql create mode 100644 db/routines/vn/triggers/itemType_beforeInsert.sql create mode 100644 db/versions/11297-graySalal/00-firstScript.sql create mode 100644 modules/item/back/models/item-type-log.json diff --git a/db/routines/vn/triggers/itemType_afterDelete.sql b/db/routines/vn/triggers/itemType_afterDelete.sql new file mode 100644 index 000000000..32a1ba31c --- /dev/null +++ b/db/routines/vn/triggers/itemType_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_afterDelete` + AFTER DELETE ON `itemType` + FOR EACH ROW +BEGIN + INSERT INTO itemTypeLog + SET `action` = 'delete', + `changedModel` = 'ItemType', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/itemType_beforeInsert.sql b/db/routines/vn/triggers/itemType_beforeInsert.sql new file mode 100644 index 000000000..d33d8fb56 --- /dev/null +++ b/db/routines/vn/triggers/itemType_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_beforeInsert` + BEFORE INSERT ON `itemType` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/itemType_beforeUpdate.sql b/db/routines/vn/triggers/itemType_beforeUpdate.sql index 613ae8bfa..6a03d40d0 100644 --- a/db/routines/vn/triggers/itemType_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemType_beforeUpdate.sql @@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_beforeUpdate` BEFORE UPDATE ON `itemType` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); IF NEW.itemPackingTypeFk = '' THEN SET NEW.itemPackingTypeFk = NULL; diff --git a/db/routines/vn/triggers/productionConfig_afterDelete.sql b/db/routines/vn/triggers/productionConfig_afterDelete.sql index 6b6800d4f..bd485d590 100644 --- a/db/routines/vn/triggers/productionConfig_afterDelete.sql +++ b/db/routines/vn/triggers/productionConfig_afterDelete.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`productionConfig_afterD AFTER DELETE ON `productionConfig` FOR EACH ROW BEGIN - INSERT INTO productionConfig + INSERT INTO productionConfigLog SET `action` = 'delete', `changedModel` = 'ProductionConfig', `changedModelId` = OLD.id, diff --git a/db/versions/11297-graySalal/00-firstScript.sql b/db/versions/11297-graySalal/00-firstScript.sql new file mode 100644 index 000000000..d6aeb1ec2 --- /dev/null +++ b/db/versions/11297-graySalal/00-firstScript.sql @@ -0,0 +1,24 @@ +ALTER TABLE vn.itemType + ADD editorFk int(10) unsigned DEFAULT NULL NULL, + ADD CONSTRAINT itemType_user_FK FOREIGN KEY (editorFk) REFERENCES account.`user`(id); + +CREATE TABLE `vn`.`itemTypeLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('ItemType') NOT NULL DEFAULT 'ItemType', + `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, + `summaryId` varchar(30) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `itemTypeLogUserFk_idx` (`userFk`), + KEY `itemTypeLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `itemTypeLog_originFk` (`originFk`,`creationDate`), + KEY `itemTypeLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, + CONSTRAINT `itemTypeLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; diff --git a/modules/item/back/models/item-type-log.json b/modules/item/back/models/item-type-log.json new file mode 100644 index 000000000..61e27e9ba --- /dev/null +++ b/modules/item/back/models/item-type-log.json @@ -0,0 +1,9 @@ +{ + "name": "ItemTypeLog", + "base": "Log", + "options": { + "mysql": { + "table": "ItemTypeLog" + } + } +} From 6c621726334adf2a4e93816c7dfceac28f9a6009 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 14 Oct 2024 09:31:35 +0200 Subject: [PATCH 2/4] feat: refs #7006 itemTypeLog created --- db/versions/11297-graySalal/00-firstScript.sql | 3 +++ modules/item/back/model-config.json | 3 +++ modules/item/back/models/item-type-log.json | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/db/versions/11297-graySalal/00-firstScript.sql b/db/versions/11297-graySalal/00-firstScript.sql index d6aeb1ec2..372af804c 100644 --- a/db/versions/11297-graySalal/00-firstScript.sql +++ b/db/versions/11297-graySalal/00-firstScript.sql @@ -22,3 +22,6 @@ CREATE TABLE `vn`.`itemTypeLog` ( KEY `itemTypeLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `itemTypeLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; + +INSERT IGNORE INTO salix.ACL (model,property,principalId) + VALUES ('ItemTypeLog','*','employee'); diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index 5dbe4d62a..dcd973524 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -47,6 +47,9 @@ "ItemType": { "dataSource": "vn" }, + "ItemTypeLog": { + "dataSource": "vn" + }, "ItemTypeTag": { "dataSource": "vn" }, diff --git a/modules/item/back/models/item-type-log.json b/modules/item/back/models/item-type-log.json index 61e27e9ba..82a218aa6 100644 --- a/modules/item/back/models/item-type-log.json +++ b/modules/item/back/models/item-type-log.json @@ -3,7 +3,7 @@ "base": "Log", "options": { "mysql": { - "table": "ItemTypeLog" + "table": "itemTypeLog" } } } From 80764b6495290a5e9090114956fc5260df53f42f Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 25 Oct 2024 14:17:57 +0200 Subject: [PATCH 3/4] feat: refs #7006 itemTypeLog --- db/versions/11297-graySalal/01-firstScript.sql | 3 +++ modules/item/back/models/item-type.json | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 db/versions/11297-graySalal/01-firstScript.sql diff --git a/db/versions/11297-graySalal/01-firstScript.sql b/db/versions/11297-graySalal/01-firstScript.sql new file mode 100644 index 000000000..78ce1a540 --- /dev/null +++ b/db/versions/11297-graySalal/01-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.itemType + ADD CONSTRAINT itemType_itemPackingType_FK FOREIGN KEY (itemPackingTypeFk) + REFERENCES vn.itemPackingType(code) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json index c5c920b2f..88f66899e 100644 --- a/modules/item/back/models/item-type.json +++ b/modules/item/back/models/item-type.json @@ -29,6 +29,12 @@ }, "isLaid": { "type": "boolean" + }, + "maxRefs": { + "type": "string" + }, + "isFragile": { + "type": "boolean" } }, "relations": { From 14d6eb722ee5087402b3d213a1d5f1b6399d53fe Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 25 Oct 2024 14:24:26 +0200 Subject: [PATCH 4/4] feat: refs #7006 Requested changes --- db/versions/11297-graySalal/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11297-graySalal/00-firstScript.sql b/db/versions/11297-graySalal/00-firstScript.sql index 372af804c..4d4711306 100644 --- a/db/versions/11297-graySalal/00-firstScript.sql +++ b/db/versions/11297-graySalal/00-firstScript.sql @@ -24,4 +24,4 @@ CREATE TABLE `vn`.`itemTypeLog` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; INSERT IGNORE INTO salix.ACL (model,property,principalId) - VALUES ('ItemTypeLog','*','employee'); + VALUES ('ItemTypeLog','find','employee');