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

task: added migration for release plan template permissions #8707

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Changes from all 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
30 changes: 30 additions & 0 deletions src/migrations/20241111085745-release-plan-template-permissions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
exports.up = (db, cb) => {
db.runSql(`
INSERT INTO permissions(permission, display_name, type) VALUES
('RELEASE_PLAN_TEMPLATE_VIEW_OVERVIEW', 'View overview of release plan templates', 'root'),
('RELEASE_PLAN_TEMPLATE_VIEW', 'View details of specific release plan template', 'root'),
('RELEASE_PLAN_TEMPLATE_CREATE', 'Create release plan template', 'root'),
('RELEASE_PLAN_TEMPLATE_UPDATE', 'Update release plan template', 'root'),
('RELEASE_PLAN_TEMPLATE_DELETE', 'Delete release plan template', 'root');
INSERT INTO role_permission(role_id, permission, created_by_user_id)
SELECT id, 'RELEASE_PLAN_TEMPLATE_VIEW_OVERVIEW', '-1337' FROM roles WHERE name IN ('Viewer', 'Editor') AND type = 'root';
INSERT INTO role_permission(role_id, permission, created_by_user_id)
SELECT id, 'RELEASE_PLAN_TEMPLATE_VIEW', '-1337' FROM roles WHERE name = 'Editor' AND type = 'root';
INSERT INTO role_permission(role_id, permission, created_by_user_id)
SELECT id, 'RELEASE_PLAN_TEMPLATE_CREATE', '-1337' FROM roles WHERE name = 'Editor' AND type = 'root';
INSERT INTO role_permission(role_id, permission, created_by_user_id)
SELECT id, 'RELEASE_PLAN_TEMPLATE_UPDATE', '-1337' FROM roles WHERE name = 'Editor' AND type = 'root';
`, cb);

};

exports.down = (db, cb) => {
db.runSql(`
DELETE
FROM permissions
WHERE permission IN
('RELEASE_PLAN_TEMPLATE_VIEW_OVERVIEW', 'RELEASE_PLAN_TEMPLATE_VIEW', 'RELEASE_PLAN_TEMPLATE_CREATE',
'RELEASE_PLAN_TEMPLATE_UPDATE', 'RELEASE_PLAN_TEMPLATE_DELETE');
`, cb);
};