diff --git a/core/server/data/migrations/versions/3.23/04-add-meta-columns-to-tags-table.js b/core/server/data/migrations/versions/3.23/04-add-meta-columns-to-tags-table.js new file mode 100644 index 0000000000..29f6098d4c --- /dev/null +++ b/core/server/data/migrations/versions/3.23/04-add-meta-columns-to-tags-table.js @@ -0,0 +1,97 @@ +const commands = require('../../../schema').commands; + +const newColumns = [{ + column: 'og_image', + columnDefinition: { + type: 'string', + maxlength: 2000, + nullable: true + } +}, { + column: 'og_title', + columnDefinition: { + type: 'string', + maxlength: 300, + nullable: true + } +}, { + column: 'og_description', + columnDefinition: { + type: 'string', + maxlength: 500, + nullable: true + } +}, { + column: 'twitter_image', + columnDefinition: { + type: 'string', + maxlength: 2000, + nullable: true + } +}, { + column: 'twitter_title', + columnDefinition: { + type: 'string', + maxlength: 300, + nullable: true + } +}, { + column: 'twitter_description', + columnDefinition: { + type: 'string', + maxlength: 500, + nullable: true + } +}, { + column: 'codeinjection_head', + columnDefinition: { + type: 'text', + maxlength: 65535, + nullable: true + } +}, { + column: 'codeinjection_foot', + columnDefinition: { + type: 'text', + maxlength: 65535, + nullable: true + } +}, { + column: 'canonical_url', + columnDefinition: { + type: 'string', + maxlength: 2000, + nullable: true + } +}, { + column: 'accent_color', + columnDefinition: { + type: 'string', + maxlength: 50, + nullable: true + } +}]; + +module.exports = { + config: { + transaction: true + }, + + up: commands.createColumnMigration(...newColumns.map((column) => { + return Object.assign({}, column, { + table: 'tags', + dbIsInCorrectState: hasColumn => hasColumn === true, + operation: commands.addColumn, + operationVerb: 'Adding' + }); + })), + + down: commands.createColumnMigration(...newColumns.map((column) => { + return Object.assign({}, column, { + table: 'tags', + dbIsInCorrectState: hasColumn => hasColumn === false, + operation: commands.dropColumn, + operationVerb: 'Removing' + }); + })) +}; diff --git a/core/server/data/schema/schema.js b/core/server/data/schema/schema.js index c47fea22d8..e83a0a3d53 100644 --- a/core/server/data/schema/schema.js +++ b/core/server/data/schema/schema.js @@ -205,8 +205,18 @@ module.exports = { defaultTo: 'public', validations: {isIn: [['public', 'internal']]} }, + og_image: {type: 'string', maxlength: 2000, nullable: true}, + og_title: {type: 'string', maxlength: 300, nullable: true}, + og_description: {type: 'string', maxlength: 500, nullable: true}, + twitter_image: {type: 'string', maxlength: 2000, nullable: true}, + twitter_title: {type: 'string', maxlength: 300, nullable: true}, + twitter_description: {type: 'string', maxlength: 500, nullable: true}, meta_title: {type: 'string', maxlength: 2000, nullable: true, validations: {isLength: {max: 300}}}, meta_description: {type: 'string', maxlength: 2000, nullable: true, validations: {isLength: {max: 500}}}, + codeinjection_head: {type: 'text', maxlength: 65535, nullable: true}, + codeinjection_foot: {type: 'text', maxlength: 65535, nullable: true}, + canonical_url: {type: 'string', maxlength: 2000, nullable: true}, + accent_color: {type: 'string', maxlength: 50, 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/test/unit/data/schema/integrity_spec.js b/test/unit/data/schema/integrity_spec.js index abe5477729..ef1a39d8e8 100644 --- a/test/unit/data/schema/integrity_spec.js +++ b/test/unit/data/schema/integrity_spec.js @@ -19,7 +19,7 @@ const fixtures = require('../../../../core/server/data/schema/fixtures'); */ describe('DB version integrity', function () { // Only these variables should need updating - const currentSchemaHash = '74b599e66e9d28c591cb7a3d9ec528cf'; + const currentSchemaHash = '134c9de4e59b31ec6b73f03638a01396'; const currentFixturesHash = '3d942c46e8487c4aee1e9ac898ed29ca'; // If this test is failing, then it is likely a change has been made that requires a DB version bump,