Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: editor can add dependencies in default project #8077

Merged
merged 6 commits into from
Sep 4, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
exports.up = function (db, cb) {
db.runSql(
`
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')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prevent a case where someone manually deleted editor

AND NOT EXISTS (
SELECT 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prevent double insert

FROM role_permission rp
WHERE rp.role_id = (SELECT id FROM roles WHERE name = 'Editor')
AND rp.permission = 'UPDATE_FEATURE_DEPENDENCY'
);
`,
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'
AND EXISTS (SELECT 1 FROM roles WHERE name = 'Editor');
`,
cb
);
};
Loading