diff --git a/src/migrations/20210428103922-patch-role-table.js b/src/migrations/20210428103922-patch-role-table.js new file mode 100644 index 0000000000..717f444e60 --- /dev/null +++ b/src/migrations/20210428103922-patch-role-table.js @@ -0,0 +1,24 @@ +'use strict'; + +const async = require('async'); + +function resolveRoleName(permissions) { + if (!permissions || permissions.length === 0) { + return 'Viewer'; + } + if (permissions.includes('ADMIN')) { + return 'Admin'; + } + return 'Editor'; +} + +exports.up = function (db, cb) { + db.runSql( + 'ALTER TABLE roles ADD COLUMN IF NOT EXISTS project text', cb + ); +}; + +exports.down = function (db, cb) { + // We can't just remove roles for users as we don't know if there has been any manual additions. + cb(); +};