diff --git a/core/server/data/migrations/versions/2.31/1-remove-name-and-password-from-members-table.js b/core/server/data/migrations/versions/2.31/1-remove-name-and-password-from-members-table.js new file mode 100644 index 0000000000..82dd91a55b --- /dev/null +++ b/core/server/data/migrations/versions/2.31/1-remove-name-and-password-from-members-table.js @@ -0,0 +1,55 @@ +const commands = require('../../../schema').commands; + +module.exports = { + + up: commands.createColumnMigration({ + table: 'members', + column: 'password', + dbIsInCorrectState(hasColumn) { + return hasColumn === false; + }, + operation: commands.dropColumn, + operationVerb: 'Dropping' + }, { + table: 'members', + column: 'name', + dbIsInCorrectState(hasColumn) { + return hasColumn === false; + }, + operation: commands.dropColumn, + operationVerb: 'Dropping' + }), + + down: commands.createColumnMigration({ + table: 'members', + column: 'password', + dbIsInCorrectState(hasColumn) { + return hasColumn === true; + }, + operation: commands.addColumn, + operationVerb: 'Adding', + columnDefinition: { + type: 'string', + maxlength: 60, + nullable: true + } + }, { + table: 'members', + column: 'name', + dbIsInCorrectState(hasColumn) { + return hasColumn === true; + }, + operation: commands.addColumn, + operationVerb: 'Adding', + columnDefinition: { + type: 'string', + maxlength: 191, + nullable: false, + defaultTo: '' + } + }), + + config: { + transaction: true + } +}; diff --git a/core/server/data/schema/schema.js b/core/server/data/schema/schema.js index 7f0cf495aa..be34d975a1 100644 --- a/core/server/data/schema/schema.js +++ b/core/server/data/schema/schema.js @@ -385,8 +385,6 @@ module.exports = { members: { id: {type: 'string', maxlength: 24, nullable: false, primary: true}, email: {type: 'string', maxlength: 191, nullable: false, unique: true, validations: {isEmail: true}}, - name: {type: 'string', maxlength: 191, nullable: false}, - password: {type: 'string', maxlength: 60, nullable: true}, created_at: {type: 'dateTime', nullable: false}, created_by: {type: 'string', maxlength: 24, nullable: false}, updated_at: {type: 'dateTime', nullable: true}, diff --git a/core/test/unit/data/schema/integrity_spec.js b/core/test/unit/data/schema/integrity_spec.js index ad73112448..a2d77fa76a 100644 --- a/core/test/unit/data/schema/integrity_spec.js +++ b/core/test/unit/data/schema/integrity_spec.js @@ -19,7 +19,7 @@ var should = require('should'), */ describe('DB version integrity', function () { // Only these variables should need updating - const currentSchemaHash = 'fda0398e93a74b2dc435cb4c026679ba'; + const currentSchemaHash = '0545d6c54975ad00004d6287c8bc853a'; const currentFixturesHash = 'c7b485fe2f16517295bd35c761129729'; // If this test is failing, then it is likely a change has been made that requires a DB version bump,