0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Added members_subscription_created_events table & model

refs https://github.com/TryGhost/Team/issues/1803
This commit is contained in:
Fabien "egg" O'Carroll 2022-08-16 18:35:11 -04:00 committed by Fabien 'egg' O'Carroll
parent 03155a61ff
commit 37ef0582e6
6 changed files with 53 additions and 2 deletions

View file

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

View file

@ -0,0 +1,11 @@
const {addTable} = require('../../utils');
module.exports = addTable('members_subscription_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},
subscription_id: {type: 'string', maxlength: 24, nullable: false, references: 'members_stripe_customers_subscriptions.id'},
attribution_id: {type: 'string', maxlength: 24, nullable: true},
attribution_type: {type: 'string', maxlength: 50, nullable: true},
attribution_url: {type: 'string', maxlength: 2000, nullable: true}
});

View file

@ -603,6 +603,15 @@ module.exports = {
plan_amount: {type: 'integer', nullable: false},
plan_currency: {type: 'string', maxLength: 3, nullable: false}
},
members_subscription_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},
subscription_id: {type: 'string', maxlength: 24, nullable: false, references: 'members_stripe_customers_subscriptions.id'},
attribution_id: {type: 'string', maxlength: 24, nullable: true},
attribution_type: {type: 'string', maxlength: 50, nullable: true},
attribution_url: {type: 'string', maxlength: 2000, nullable: true}
},
offer_redemptions: {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
offer_id: {type: 'string', maxlength: 24, nullable: false, references: 'offers.id', cascadeDelete: true},

View file

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

View file

@ -51,7 +51,7 @@ describe('Exporter', function () {
'members_stripe_customers_subscriptions',
'members_subscribe_events',
'members_created_events',
'subscription_created_events',
'members_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 = 'f5f7bc63bf9484bf50a0e554604802b3';
const currentSchemaHash = '36796d1729450e8d2184bb5360067919';
const currentFixturesHash = '0ae1887dd0b42508be946bdbd20d41c8';
const currentSettingsHash = 'd54210758b7054e2174fd34aa2320ad7';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';