diff --git a/core/server/data/migrations/versions/3.38/01-add-email-recipient-filter-column.js b/core/server/data/migrations/versions/3.38/01-add-email-recipient-filter-column.js new file mode 100644 index 0000000000..f87ce60651 --- /dev/null +++ b/core/server/data/migrations/versions/3.38/01-add-email-recipient-filter-column.js @@ -0,0 +1,25 @@ +const {createColumnMigration, addColumn, dropColumn} = require('../../../schema/commands'); + +module.exports = { + up: createColumnMigration({ + table: 'posts', + column: 'email_recipient_filter', + dbIsInCorrectState: hasColumn => !!hasColumn, + operation: addColumn, + operationVerb: 'Adding', + columnDefinition: { + type: 'string', + maxlength: 50, + nullable: false, + defaultTo: 'none', + validations: {isIn: [['none', 'all', 'free', 'paid']]} + } + }), + down: createColumnMigration({ + table: 'posts', + column: 'email_recipient_filter', + dbIsInCorrectState: hasColumn => !hasColumn, + operation: dropColumn, + operationVerb: 'Removing' + }) +}; diff --git a/core/server/data/schema/schema.js b/core/server/data/schema/schema.js index ff1b5a9992..fdfdd5a7ab 100644 --- a/core/server/data/schema/schema.js +++ b/core/server/data/schema/schema.js @@ -30,6 +30,13 @@ module.exports = { validations: {isIn: [['public', 'members', 'paid']]} }, send_email_when_published: {type: 'bool', nullable: true, defaultTo: false}, + email_recipient_filter: { + type: 'string', + maxlength: 50, + nullable: false, + defaultTo: 'none', + validations: {isIn: [['none', 'all', 'free', 'paid']]} + }, /** * @deprecated: `author_id`, might be removed in Ghost 3.0 * If we keep it, then only, because you can easier query post.author_id than posts_authors[*].sort_order. diff --git a/core/server/models/post.js b/core/server/models/post.js index e47bc07fe2..58bc1cb321 100644 --- a/core/server/models/post.js +++ b/core/server/models/post.js @@ -55,7 +55,8 @@ Post = ghostBookshelf.Model.extend({ status: 'draft', featured: false, type: 'post', - visibility: visibility + visibility: visibility, + email_recipient_filter: 'none' }; }, diff --git a/test/unit/data/schema/integrity_spec.js b/test/unit/data/schema/integrity_spec.js index bdba693705..51fccd7e8d 100644 --- a/test/unit/data/schema/integrity_spec.js +++ b/test/unit/data/schema/integrity_spec.js @@ -32,7 +32,7 @@ const defaultSettings = require('../../../../core/server/data/schema/default-set */ describe('DB version integrity', function () { // Only these variables should need updating - const currentSchemaHash = 'c4de64f1c1114eb8b05c7473e3adc29e'; + const currentSchemaHash = '7d841714b01e6d880d4d8a739ab62bff'; const currentFixturesHash = 'd46d696c94d03e41a5903500547fea77'; const currentSettingsHash = 'c8daa2c9632bb75f9d60655de09ae3bd'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';