1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-14 00:19:16 +01:00

fix: connect admin user with admin role

(bug from 3.13.0)
This commit is contained in:
Ivar Conradi Østhus 2022-02-23 11:29:41 +01:00
parent d52b68e918
commit f799f06bf3
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09

View File

@ -0,0 +1,27 @@
'use strict';
exports.up = function (db, cb) {
db.runSql(
`
DO $$
declare
begin
WITH admin AS (
SELECT * FROM roles WHERE name in ('Admin', 'Super User') LIMIT 1
)
INSERT into role_user(role_id, user_id)
VALUES
((select id from admin), (select id FROM users where username='admin' LIMIT 1));
EXCEPTION WHEN OTHERS THEN
raise notice 'Ignored';
end;
$$;`,
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();
};