From 38bea60776d2ccc3dd18d7e35b332f26f56cb4d9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 31 May 2024 09:49:58 +0200 Subject: [PATCH] refactor: refs #6889 script sql --- .../00-createRoleProductionReviewer.sql | 18 -------- .../11060-tealGalax/00-createRoleReviewer.sql | 46 +++++++++++++++++++ 2 files changed, 46 insertions(+), 18 deletions(-) delete mode 100644 db/versions/11060-tealGalax/00-createRoleProductionReviewer.sql create mode 100644 db/versions/11060-tealGalax/00-createRoleReviewer.sql diff --git a/db/versions/11060-tealGalax/00-createRoleProductionReviewer.sql b/db/versions/11060-tealGalax/00-createRoleProductionReviewer.sql deleted file mode 100644 index ad3e2f5b2..000000000 --- a/db/versions/11060-tealGalax/00-createRoleProductionReviewer.sql +++ /dev/null @@ -1,18 +0,0 @@ -INSERT INTO account.role - SET name = 'productionReviewer', - description = 'Revisor de producción', - hasLogin = TRUE, - created = util.VN_CURDATE(), - modified = util.VN_CURDATE(), - editorFk = NULL; - --- UPDATE salix.ACL --- SET principalId = 'productionReviewer' --- WHERE property = 'isInPreparing'; - -UPDATE account.user u - JOIN vn.workerDepartment wd ON wd.workerFk = u.id - JOIN vn.department d ON wd.departmentFk = d.id - JOIN account.role r ON r.name = 'productionReviewer' - SET u.role = r.id - WHERE d.name = 'REVISION'; \ No newline at end of file diff --git a/db/versions/11060-tealGalax/00-createRoleReviewer.sql b/db/versions/11060-tealGalax/00-createRoleReviewer.sql new file mode 100644 index 000000000..21cb43434 --- /dev/null +++ b/db/versions/11060-tealGalax/00-createRoleReviewer.sql @@ -0,0 +1,46 @@ +use account; + +INSERT INTO account.role + SET name = 'reviewer', + description = 'Revisor de producción', + hasLogin = TRUE, + created = util.VN_CURDATE(), + modified = util.VN_CURDATE(), + editorFk = NULL; + +INSERT IGNORE INTO account.roleInherit( + role, + inheritsFrom +) + SELECT r1.id, + r2.id + FROM account.role r1 + JOIN account.role r2 + WHERE r2.name = 'production' + AND r1.name = 'reviewer' + UNION + SELECT ri.role, + r2.id + FROM account.roleInherit ri + JOIN account.role r1 ON r1.id = ri.role + JOIN account.role r2 ON r2.name = 'reviewer' + WHERE r1.name IN ('claimManager', 'productionBoss') + GROUP BY ri.role; + +DELETE ri + FROM account.roleInherit ri + JOIN account.role r1 ON ri.role = r1.id + JOIN account.role r2 ON ri.inheritsFrom = r2.id + WHERE r1.name = 'replenisher' + AND r2.name = 'buyer'; + +UPDATE salix.ACL + SET principalId = 'reviewer' + WHERE property = 'isInPreparing'; + +UPDATE account.user u + JOIN vn.workerDepartment wd ON wd.workerFk = u.id + JOIN vn.department d ON wd.departmentFk = d.id + JOIN account.role r ON r.name = 'reviewer' + SET u.role = r.id + WHERE d.name IN ('REVISION', 'PREVIA'); \ No newline at end of file