Added table to store multiple newsletters for member (#14408)

refs https://github.com/TryGhost/Team/issues/1469

With multiple newsletters, members will now be able to subscribe to one or more newsletters on the site. Previously, the subscription to default newsletter for a member was controlled via a single boolean `subscribed` column on the member table.
This change allows mapping multiple newsletters to a member via new pivot table that stores relation between a member and newsletter.

- adds new `members_newsletters` pivot table
- update tests
This commit is contained in:
Rishabh Garg 2022-04-04 18:11:36 +05:30 committed by GitHub
parent eddb77e204
commit ee0a6910ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 1 deletions

View File

@ -40,6 +40,7 @@ const BACKUP_TABLES = [
'members_paid_subscription_events',
'members_subscribe_events',
'members_product_events',
'members_newsletters',
'offers',
'offer_redemptions'
];

View File

@ -0,0 +1,7 @@
const {addTable} = require('../../utils');
module.exports = addTable('members_newsletters', {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
newsletter_id: {type: 'string', maxlength: 24, nullable: false, references: 'newsletters.id', cascadeDelete: true}
});

View File

@ -729,5 +729,10 @@ module.exports = {
},
subscribe_on_signup: {type: 'bool', nullable: false, defaultTo: false},
sort_order: {type: 'integer', nullable: false, unsigned: true, defaultTo: 0}
},
members_newsletters: {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
newsletter_id: {type: 'string', maxlength: 24, nullable: false, references: 'newsletters.id', cascadeDelete: true}
}
};

View File

@ -37,6 +37,7 @@ describe('Exporter', function () {
'members_email_change_events',
'members_labels',
'members_login_events',
'members_newsletters',
'members_paid_subscription_events',
'members_payment_events',
'members_products',

View File

@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route
*/
describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = 'adaab19330ba19ed2d0cba49458c8f21';
const currentSchemaHash = '8bf6c2996ddd0238d41a9d3e1cb07bd9';
const currentFixturesHash = 'f4dd2a454e1999b6d149cc26ae52ced4';
const currentSettingsHash = '71fa38d0c805c18ceebe0fda80886230';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';