salix/db/versions/11060-tealGalax/00-createRoleReviewer.sql

46 lines
1.0 KiB
MySQL
Raw Permalink Normal View History

2024-05-31 07:49:58 +00:00
use account;
2024-05-31 10:51:06 +00:00
INSERT INTO role
2024-05-31 07:49:58 +00:00
SET name = 'reviewer',
description = 'Revisor de producción',
hasLogin = TRUE,
created = util.VN_CURDATE(),
modified = util.VN_CURDATE(),
editorFk = NULL;
2024-05-31 10:51:06 +00:00
INSERT INTO roleInherit(
2024-05-31 07:49:58 +00:00
role,
inheritsFrom
)
SELECT r1.id,
r2.id
2024-05-31 10:51:06 +00:00
FROM role r1
JOIN role r2
WHERE r1.name = 'reviewer'
AND r2.name = 'production'
2024-05-31 07:49:58 +00:00
UNION
SELECT ri.role,
r2.id
2024-05-31 10:51:06 +00:00
FROM roleInherit ri
JOIN role r1 ON r1.id = ri.role
JOIN role r2 ON r2.name = 'reviewer'
2024-05-31 07:49:58 +00:00
WHERE r1.name IN ('claimManager', 'productionBoss')
GROUP BY ri.role;
DELETE ri
2024-05-31 10:51:06 +00:00
FROM roleInherit ri
JOIN role r1 ON ri.role = r1.id
JOIN role r2 ON ri.inheritsFrom = r2.id
2024-05-31 07:49:58 +00:00
WHERE r1.name = 'replenisher'
AND r2.name = 'buyer';
UPDATE salix.ACL
SET principalId = 'reviewer'
WHERE property = 'isInPreparing';
2024-05-31 10:51:06 +00:00
UPDATE user u
2024-05-31 07:49:58 +00:00
JOIN vn.workerDepartment wd ON wd.workerFk = u.id
JOIN vn.department d ON wd.departmentFk = d.id
2024-05-31 10:51:06 +00:00
JOIN role r ON r.name = 'reviewer'
2024-05-31 07:49:58 +00:00
SET u.role = r.id
WHERE d.name IN ('REVISION', 'PREVIA');