Skip to content

Commit

Permalink
chore: add migration that adds is_system column and inserts system user
Browse files Browse the repository at this point in the history
  • Loading branch information
daveleek committed Dec 12, 2023
1 parent 205d844 commit 013b0d6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/migrations/20231212094343-unleash-system-user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

exports.up = function (db, callback) {
db.runSql(
`
ALTER TABLE users ADD COLUMN IF NOT EXISTS is_system BOOLEAN NOT NULL DEFAULT FALSE;
DELETE FROM users WHERE id = -1337;
INSERT INTO users
(id, name, username, email, created_by, is_system)
VALUES
(-1337, 'Used by unleash internally for performing system actions that have no user', 'unleash_system_user', '[email protected]', -1337, true);
`,
callback,
);
};

exports.down = function (db, callback) {
db.runSql(
`
ALTER TABLE users DROP COLUMN IF EXISTS is_system;
DELETE FROM users WHERE id = -1337;
`,
callback,
);
};

0 comments on commit 013b0d6

Please sign in to comment.