From d54be917d17fd754c082bce8e20fb0d6f8c5e3ca Mon Sep 17 00:00:00 2001 From: Naz Gargol Date: Wed, 25 Sep 2019 10:44:50 +0200 Subject: [PATCH] Added name column back to members table (#11151) refs https://github.com/TryGhost/Ghost/commit/294f3769cb59cd04478122896ad7743a991337aa - We have a need for name field now :) - This time `name` is nullable ! --- .../2.32/1-add-name-to-members-table.js | 28 +++++++++++++++++++ core/server/data/schema/schema.js | 1 + core/test/unit/data/schema/integrity_spec.js | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 core/server/data/migrations/versions/2.32/1-add-name-to-members-table.js diff --git a/core/server/data/migrations/versions/2.32/1-add-name-to-members-table.js b/core/server/data/migrations/versions/2.32/1-add-name-to-members-table.js new file mode 100644 index 0000000000..651d60aac8 --- /dev/null +++ b/core/server/data/migrations/versions/2.32/1-add-name-to-members-table.js @@ -0,0 +1,28 @@ +const commands = require('../../../schema').commands; + +module.exports = { + + up: commands.createColumnMigration({ + table: 'members', + column: 'name', + dbIsInCorrectState(hasColumn) { + return hasColumn === true; + }, + operation: commands.addColumn, + operationVerb: 'Adding' + }), + + down: commands.createColumnMigration({ + table: 'members', + column: 'name', + dbIsInCorrectState(hasColumn) { + return hasColumn === false; + }, + operation: commands.dropColumn, + operationVerb: 'Dropping' + }), + + config: { + transaction: true + } +}; diff --git a/core/server/data/schema/schema.js b/core/server/data/schema/schema.js index c9323f41cd..c0a2ffc5b8 100644 --- a/core/server/data/schema/schema.js +++ b/core/server/data/schema/schema.js @@ -385,6 +385,7 @@ 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: 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 bd1e580798..cffff0014a 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 = '988ec6aa45840b4d15e16d5b1d2a9976'; + const currentSchemaHash = 'a503d46e2333202f00fa2bc835b064d2'; const currentFixturesHash = 'c7b485fe2f16517295bd35c761129729'; // If this test is failing, then it is likely a change has been made that requires a DB version bump,