diff --git a/core/server/data/exporter/table-lists.js b/core/server/data/exporter/table-lists.js index cd354454c2..b8f241d077 100644 --- a/core/server/data/exporter/table-lists.js +++ b/core/server/data/exporter/table-lists.js @@ -15,6 +15,7 @@ const BACKUP_TABLES = [ 'members_stripe_customers_subscriptions', 'migrations', 'migrations_lock', + 'newsletters', 'oauth', 'permissions', 'permissions_roles', diff --git a/core/server/data/migrations/versions/4.42/2022-03-21-17-17-add.js b/core/server/data/migrations/versions/4.42/2022-03-21-17-17-add.js new file mode 100644 index 0000000000..62763126f4 --- /dev/null +++ b/core/server/data/migrations/versions/4.42/2022-03-21-17-17-add.js @@ -0,0 +1,20 @@ +const {addTable} = require('../../utils'); + +module.exports = addTable('newsletters', { + id: {type: 'string', maxlength: 24, nullable: false, primary: true}, + name: {type: 'string', maxlength: 191, nullable: false}, + description: {type: 'string', maxlength: 2000, nullable: true}, + sender_name: {type: 'string', maxlength: 191, nullable: false}, + sender_email: {type: 'string', maxlength: 191, nullable: false, validations: {isEmail: true}}, + sender_reply_to: {type: 'string', maxlength: 191, nullable: false, validations: {isEmail: true}}, + default: {type: 'bool', nullable: false, defaultTo: false}, + status: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'active'}, + recipient_filter: { + type: 'text', + maxlength: 1000000000, + nullable: false, + defaultTo: '' + }, + subscribe_on_signup: {type: 'bool', nullable: false, defaultTo: false}, + sort_order: {type: 'integer', nullable: false, unsigned: true, defaultTo: 0} +}); diff --git a/core/server/data/schema/schema.js b/core/server/data/schema/schema.js index 4ea90b7798..2ed070de8a 100644 --- a/core/server/data/schema/schema.js +++ b/core/server/data/schema/schema.js @@ -711,5 +711,23 @@ module.exports = { } }, value: {type: 'text', maxlength: 65535, nullable: true} + }, + newsletters: { + id: {type: 'string', maxlength: 24, nullable: false, primary: true}, + name: {type: 'string', maxlength: 191, nullable: false}, + description: {type: 'string', maxlength: 2000, nullable: true}, + sender_name: {type: 'string', maxlength: 191, nullable: false}, + sender_email: {type: 'string', maxlength: 191, nullable: false, validations: {isEmail: true}}, + sender_reply_to: {type: 'string', maxlength: 191, nullable: false, validations: {isEmail: true}}, + default: {type: 'bool', nullable: false, defaultTo: false}, + status: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'active'}, + recipient_filter: { + type: 'text', + maxlength: 1000000000, + nullable: false, + defaultTo: '' + }, + subscribe_on_signup: {type: 'bool', nullable: false, defaultTo: false}, + sort_order: {type: 'integer', nullable: false, unsigned: true, defaultTo: 0} } }; diff --git a/test/integration/exporter/exporter.test.js b/test/integration/exporter/exporter.test.js index 0a6b414c0e..d3a1eef617 100644 --- a/test/integration/exporter/exporter.test.js +++ b/test/integration/exporter/exporter.test.js @@ -49,6 +49,7 @@ describe('Exporter', function () { 'migrations', 'migrations_lock', 'mobiledoc_revisions', + 'newsletters', 'oauth', 'offers', 'offer_redemptions', diff --git a/test/unit/server/data/schema/integrity.test.js b/test/unit/server/data/schema/integrity.test.js index 1414695916..6d2a935ed3 100644 --- a/test/unit/server/data/schema/integrity.test.js +++ b/test/unit/server/data/schema/integrity.test.js @@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route */ describe('DB version integrity', function () { // Only these variables should need updating - const currentSchemaHash = 'b7867be4de694b4592d748c0367064b5'; + const currentSchemaHash = 'adaab19330ba19ed2d0cba49458c8f21'; const currentFixturesHash = 'f4dd2a454e1999b6d149cc26ae52ced4'; const currentSettingsHash = '71fa38d0c805c18ceebe0fda80886230'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';