Skip to content

Commit

Permalink
fix: connect admin user with admin role
Browse files Browse the repository at this point in the history
(bug from 3.13.0)
  • Loading branch information
ivarconr committed Feb 23, 2022
1 parent d52b68e commit f799f06
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/migrations/20210428103924-patch-admin_role.js
Original file line number Diff line number Diff line change
@@ -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();
};

0 comments on commit f799f06

Please sign in to comment.