Added subscription_id to MRR events (#14445)

* Added subscription_id to MRR events

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

As part of 5.0 we want to have cancelled evetns affect MRR. We are going
to backfill and begin populating cancelled events _before_ 5.0 however,
adding a migration to set the MRR deltas as part of 5.0

This migration will need to associate the cancelled events with a
subscription, so we are adding the subscription_id now. This will allow
us to guarantee that all cancelled events will have a subscription_id.

The column is missing a NOT NULL and REFERENCES constraint because
we have not populated the missing values. These will be added in the future
once we have populated the column for all rows
This commit is contained in:
Fabien 'egg' O'Carroll 2022-04-08 14:04:40 +01:00 committed by GitHub
parent a26056d796
commit 7ff0247e8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -0,0 +1,7 @@
const {createAddColumnMigration} = require('../../utils');
module.exports = createAddColumnMigration('members_paid_subscription_events', 'subscription_id', {
type: 'string',
maxlength: 24,
nullable: true
});

View File

@ -512,6 +512,7 @@ module.exports = {
id: {type: 'string', maxlength: 24, nullable: false, primary: true}, id: {type: 'string', maxlength: 24, nullable: false, primary: true},
type: {type: 'string', maxlength: 50, nullable: true}, type: {type: 'string', maxlength: 50, nullable: true},
member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true}, member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
subscription_id: {type: 'string', maxlength: 24, nullable: true},
from_plan: {type: 'string', maxlength: 255, nullable: true}, from_plan: {type: 'string', maxlength: 255, nullable: true},
to_plan: {type: 'string', maxlength: 255, nullable: true}, to_plan: {type: 'string', maxlength: 255, nullable: true},
currency: {type: 'string', maxLength: 3, nullable: false}, currency: {type: 'string', maxLength: 3, nullable: false},

View File

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