Added members_created_events table & model

refs https://github.com/TryGhost/Team/issues/1802
This commit is contained in:
Fabien "egg" O'Carroll 2022-08-16 18:34:23 -04:00 committed by Fabien 'egg' O'Carroll
parent f18cc0185b
commit 03155a61ff
6 changed files with 50 additions and 1 deletions

View File

@ -31,6 +31,7 @@ const BACKUP_TABLES = [
'members_paid_subscription_events',
'members_subscribe_events',
'members_product_events',
'members_created_events',
'members_newsletters',
'comments',
'comment_likes',

View File

@ -0,0 +1,11 @@
const {addTable} = require('../../utils');
module.exports = addTable('members_created_events', {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
created_at: {type: 'dateTime', nullable: false},
member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
attribution_id: {type: 'string', maxlength: 24, nullable: true},
attribution_type: {type: 'string', maxlength: 50, nullable: true},
attribution_url: {type: 'string', maxlength: 2000, nullable: true},
source: {type: 'string', maxlength: 50, nullable: false}
});

View File

@ -474,6 +474,15 @@ module.exports = {
product_id: {type: 'string', maxlength: 24, nullable: false, references: 'products.id', cascadeDelete: true},
sort_order: {type: 'integer', nullable: false, unsigned: true, defaultTo: 0}
},
members_created_events: {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
created_at: {type: 'dateTime', nullable: false},
member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
attribution_id: {type: 'string', maxlength: 24, nullable: true},
attribution_type: {type: 'string', maxlength: 50, nullable: true},
attribution_url: {type: 'string', maxlength: 2000, nullable: true},
source: {type: 'string', maxlength: 50, nullable: false}
},
members_cancel_events: {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},

View File

@ -0,0 +1,26 @@
const errors = require('@tryghost/errors');
const ghostBookshelf = require('./base');
const MemberCreatedEvent = ghostBookshelf.Model.extend({
tableName: 'members_created_events',
member() {
return this.belongsTo('Member', 'member_id', 'id');
},
attribution() {
return this.belongsTo('Post', 'attribution_id', 'id');
}
}, {
async edit() {
throw new errors.IncorrectUsageError({message: 'Cannot edit MemberCreatedEvent'});
},
async destroy() {
throw new errors.IncorrectUsageError({message: 'Cannot destroy MemberCreatedEvent'});
}
});
module.exports = {
MemberCreatedEvent: ghostBookshelf.model('MemberCreatedEvent', MemberCreatedEvent)
};

View File

@ -50,6 +50,8 @@ describe('Exporter', function () {
'members_stripe_customers',
'members_stripe_customers_subscriptions',
'members_subscribe_events',
'members_created_events',
'subscription_created_events',
'migrations',
'migrations_lock',
'mobiledoc_revisions',

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 = '45337ae85129a98e4c1b551cc91790da';
const currentSchemaHash = 'f5f7bc63bf9484bf50a0e554604802b3';
const currentFixturesHash = '0ae1887dd0b42508be946bdbd20d41c8';
const currentSettingsHash = 'd54210758b7054e2174fd34aa2320ad7';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';