2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Added recipient_filter column to emails table

no-issue

This column will allow us to store the canonical recipient filter on the
email resource giving us a detailed log of which members an email was
intended for
This commit is contained in:
Fabien O'Carroll 2020-11-04 11:06:57 +00:00 committed by Fabien 'egg' O'Carroll
parent dd0f80c9fa
commit 918c721bd1
4 changed files with 34 additions and 1 deletions

View file

@ -0,0 +1,25 @@
const {createColumnMigration, addColumn, dropColumn} = require('../../../schema/commands');
module.exports = {
up: createColumnMigration({
table: 'emails',
column: 'recipient_filter',
dbIsInCorrectState: hasColumn => !!hasColumn,
operation: addColumn,
operationVerb: 'Adding',
columnDefinition: {
type: 'string',
maxlength: 50,
nullable: false,
defaultTo: 'paid',
validations: {isIn: [['all', 'free', 'paid']]}
}
}),
down: createColumnMigration({
table: 'emails',
column: 'recipient_filter',
dbIsInCorrectState: hasColumn => !hasColumn,
operation: dropColumn,
operationVerb: 'Removing'
})
};

View file

@ -453,6 +453,13 @@ module.exports = {
defaultTo: 'pending',
validations: {isIn: [['pending', 'submitting', 'submitted', 'failed']]}
},
recipient_filter: {
type: 'string',
maxlength: 50,
nullable: false,
defaultTo: 'paid',
validations: {isIn: [['all', 'free', 'paid']]}
},
error: {type: 'string', maxlength: 2000, nullable: true},
error_data: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},
meta: {type: 'text', maxlength: 65535, nullable: true},

View file

@ -8,6 +8,7 @@ const Email = ghostBookshelf.Model.extend({
return {
uuid: uuid.v4(),
status: 'pending',
recipient_filter: 'paid',
stats: JSON.stringify({
delivered: 0,
failed: 0,

View file

@ -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 = '7d841714b01e6d880d4d8a739ab62bff';
const currentSchemaHash = '875ecd7995d0dccdbc0ae64be8dfbca0';
const currentFixturesHash = 'd46d696c94d03e41a5903500547fea77';
const currentSettingsHash = 'c8daa2c9632bb75f9d60655de09ae3bd';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';