Skip to content

Commit

Permalink
fix: editor can add dependencies in default project
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Sep 4, 2024
1 parent 39b9846 commit 6540daf
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
exports.up = function (db, cb) {
db.runSql(
`
INSERT INTO role_permission (role_id, permission) SELECT id, 'UPDATE_FEATURE_DEPENDENCY' FROM roles WHERE name = 'Editor' LIMIT 1;
INSERT INTO role_permission (role_id, permission) SELECT id, 'UPDATE_FEATURE_DEPENDENCY' FROM roles WHERE name = 'Editor'
AND EXISTS (SELECT 1 FROM roles WHERE name = 'Editor')
AND NOT EXISTS (
SELECT 1
FROM role_permission rp
WHERE rp.role_id = (SELECT id FROM roles WHERE name = 'Editor')
AND rp.permission = 'UPDATE_FEATURE_DEPENDENCY'
);
`,
cb
);
Expand All @@ -10,7 +17,8 @@ exports.up = function (db, cb) {
exports.down = function (db, cb) {
db.runSql(
`
DELETE FROM role_permission WHERE role_id = (SELECT id FROM roles WHERE name = 'Editor') AND permission = 'UPDATE_FEATURE_DEPENDENCY';
DELETE FROM role_permission WHERE role_id = (SELECT id FROM roles WHERE name = 'Editor') AND permission = 'UPDATE_FEATURE_DEPENDENCY'
AND EXISTS (SELECT 1 FROM roles WHERE name = 'Editor');
`,
cb
);
Expand Down

0 comments on commit 6540daf

Please sign in to comment.