From d220aaec0f17754a5955d9064451cdc45a9c5f6e Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Wed, 4 Sep 2024 11:25:32 +0200 Subject: [PATCH] fix: editor can add dependencies in default project (#8077) --- ...14-add-update-feature-dependency-editor.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/migrations/20240904084114-add-update-feature-dependency-editor.js diff --git a/src/migrations/20240904084114-add-update-feature-dependency-editor.js b/src/migrations/20240904084114-add-update-feature-dependency-editor.js new file mode 100644 index 0000000000..4ee19b45fb --- /dev/null +++ b/src/migrations/20240904084114-add-update-feature-dependency-editor.js @@ -0,0 +1,28 @@ +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 type = 'root' + AND EXISTS (SELECT 1 FROM roles WHERE name = 'Editor' and type = 'root') + AND NOT EXISTS ( + SELECT 1 + FROM role_permission + WHERE role_permission.role_id = (SELECT id FROM roles WHERE name = 'Editor' AND type = 'root') + AND role_permission.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 type = 'root') + AND permission = 'UPDATE_FEATURE_DEPENDENCY'; + `, + cb + ); +};