refactor: refs #6889 script sql
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-05-31 09:49:58 +02:00
parent eb15262fb0
commit 38bea60776
2 changed files with 46 additions and 18 deletions

View File

@ -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';

View File

@ -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');