Added migration to fix incorrect mrr events (#12837)
closes https://github.com/TryGhost/Team/issues/595 Due to a bug in `mrr_delta` calculation, we ended up reducing the MRR delta by twice the original amount when a subscription goes from active to canceled and storing it in `members_paid_subscription_events` table, which is used to show the MRR chart on Dashboard. The way we identify the incorrect events in the table which got the double negative value is by checking if they match certain criteria - Both `from_plan` and `to_plan` have same value as a subscription changes status while being on same plan. This migration halves the `mrr_delta` for incorrect events to restore the correct MRR change for the site.
This commit is contained in:
parent
a6b3d5463d
commit
dba2a2970b
@ -0,0 +1,13 @@
|
||||
const {createTransactionalMigration} = require('../../utils');
|
||||
const logging = require('../../../../../shared/logging');
|
||||
|
||||
module.exports = createTransactionalMigration(
|
||||
async function up(knex) {
|
||||
logging.info('Fixing incorrect mrr_delta in members_paid_subscription_events table');
|
||||
await knex.raw('UPDATE members_paid_subscription_events SET mrr_delta = ROUND(mrr_delta / 2) WHERE from_plan = to_plan');
|
||||
},
|
||||
async function down(knex) {
|
||||
logging.info('Reverting mrr_delta to old value in members_paid_subscription_events table');
|
||||
await knex.raw('UPDATE members_paid_subscription_events SET mrr_delta = ROUND(mrr_delta * 2) WHERE from_plan = to_plan');
|
||||
}
|
||||
);
|
Loading…
Reference in New Issue
Block a user