mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
dfe068ee33
## About the changes
Tested manually as admin in enterprise:
![image](https://user-images.githubusercontent.com/455064/223457013-abd3a16c-5aff-427a-a8a9-32695073309b.png)
Admin should have a special permission that gives super-powers. There's
no need to have specific permissions linked to it.
Based of:
a077967760/src/migrations/20220307130902-add-segments.js (L32-L46)
36 lines
944 B
JavaScript
36 lines
944 B
JavaScript
exports.up = function (db, cb) {
|
|
db.runSql(
|
|
`
|
|
DELETE FROM role_permission
|
|
WHERE permission_id IN (
|
|
SELECT id FROM permissions WHERE permission IN (
|
|
'DELETE_SEGMENT',
|
|
'UPDATE_SEGMENT',
|
|
'CREATE_SEGMENT'
|
|
))
|
|
AND role_id IN (SELECT id FROM roles r WHERE r.name = 'Admin');
|
|
`,
|
|
cb,
|
|
);
|
|
};
|
|
|
|
exports.down = function (db, cb) {
|
|
db.runSql(
|
|
`
|
|
insert into role_permission (role_id, permission_id)
|
|
select
|
|
r.id as role_id,
|
|
p.id as permission_id
|
|
from roles r
|
|
cross join permissions p
|
|
where r.name = 'Admin'
|
|
and p.permission in (
|
|
'CREATE_SEGMENT',
|
|
'UPDATE_SEGMENT',
|
|
'DELETE_SEGMENT'
|
|
);
|
|
`,
|
|
cb,
|
|
);
|
|
};
|