From 624265407891e50dca88cb8b92b1a0ecf8eb41a5 Mon Sep 17 00:00:00 2001 From: kwasniew Date: Wed, 4 Sep 2024 10:57:37 +0200 Subject: [PATCH] fix: editor can add dependencies in default project --- ...20240904084114-add-update-feature-dependency-editor.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/migrations/20240904084114-add-update-feature-dependency-editor.js b/src/migrations/20240904084114-add-update-feature-dependency-editor.js index 06c841f4d30e..c9d39c008f54 100644 --- a/src/migrations/20240904084114-add-update-feature-dependency-editor.js +++ b/src/migrations/20240904084114-add-update-feature-dependency-editor.js @@ -1,7 +1,9 @@ exports.up = function (db, cb) { db.runSql( ` - INSERT INTO role_permission (role_id, permission) SELECT id, 'UPDATE_FEATURE_DEPENDENCY' FROM roles WHERE name = 'Editor' + 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 @@ -17,7 +19,9 @@ 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