diff --git a/migrations/20190829153300-users-add-source.js b/migrations/20190829153300-users-add-source.js new file mode 100644 index 000000000..e9d7e4a42 --- /dev/null +++ b/migrations/20190829153300-users-add-source.js @@ -0,0 +1,17 @@ +'use strict'; + +exports.up = function(db, callback) { + db.runSql('ALTER TABLE users ADD COLUMN source VARCHAR(128) DEFAULT ""', function (error) { + if (error) return callback(error); + + callback(); + }); +}; + +exports.down = function(db, callback) { + db.runSql('ALTER TABLE users DROP COLUMN source', function (error) { + if (error) console.error(error); + callback(error); + }); +}; + diff --git a/migrations/schema.sql b/migrations/schema.sql index acacce058..716d433f2 100644 --- a/migrations/schema.sql +++ b/migrations/schema.sql @@ -27,6 +27,7 @@ CREATE TABLE IF NOT EXISTS users( twoFactorAuthenticationSecret VARCHAR(128) DEFAULT "", twoFactorAuthenticationEnabled BOOLEAN DEFAULT false, admin BOOLEAN DEFAULT false, + source VARCHAR(128) DEFAULT "", PRIMARY KEY(id)); diff --git a/src/userdb.js b/src/userdb.js index bb7d397f9..2659a208f 100644 --- a/src/userdb.js +++ b/src/userdb.js @@ -25,7 +25,7 @@ var assert = require('assert'), mysql = require('mysql'); var USERS_FIELDS = [ 'id', 'username', 'email', 'fallbackEmail', 'password', 'salt', 'createdAt', 'modifiedAt', 'resetToken', 'displayName', - 'twoFactorAuthenticationEnabled', 'twoFactorAuthenticationSecret', 'admin', 'active' ].join(','); + 'twoFactorAuthenticationEnabled', 'twoFactorAuthenticationSecret', 'admin', 'active', 'source' ].join(','); function postProcess(result) { assert.strictEqual(typeof result, 'object');