diff --git a/src/migrations/20231212094343-unleash-system-user.js b/src/migrations/20231212094343-unleash-system-user.js new file mode 100644 index 000000000000..a4d7c9586163 --- /dev/null +++ b/src/migrations/20231212094343-unleash-system-user.js @@ -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', 'system@getunleash.io', -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, + ); +};