mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 11:55:01 +03:00
Handled storing of trial start/end info for subscription (#15161)
refs https://github.com/TryGhost/Team/issues/1724 With free trials, members can start subscriptions with a trial period. This change stores the information about trial start and end date for every subscription so it can be shown on Admin/Portal for member. - adds new `trial_start_at` column for storing trial start date on Stripe subscription. Will in most cases match the start of subscription date. - adds new `trial_end_at` column for storing trial end date on Stripe subscription. - wires storing trial start and end values on stripe subscription
This commit is contained in:
parent
b03ec721a2
commit
5704ac061e
@ -0,0 +1,6 @@
|
||||
const {createAddColumnMigration} = require('../../utils');
|
||||
|
||||
module.exports = createAddColumnMigration('members_stripe_customers_subscriptions', 'trial_start_at', {
|
||||
type: 'dateTime',
|
||||
nullable: true
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
const {createAddColumnMigration} = require('../../utils');
|
||||
|
||||
module.exports = createAddColumnMigration('members_stripe_customers_subscriptions', 'trial_end_at', {
|
||||
type: 'dateTime',
|
||||
nullable: true
|
||||
});
|
@ -585,6 +585,8 @@ module.exports = {
|
||||
updated_by: {type: 'string', maxlength: 24, nullable: true},
|
||||
mrr: {type: 'integer', unsigned: true, nullable: false, defaultTo: 0},
|
||||
offer_id: {type: 'string', maxlength: 24, nullable: true, unique: false, references: 'offers.id'},
|
||||
trial_start_at: {type: 'dateTime', nullable: true},
|
||||
trial_end_at: {type: 'dateTime', nullable: true},
|
||||
/* Below fields are now redundant as we link prie_id to stripe_prices table */
|
||||
plan_id: {type: 'string', maxlength: 255, nullable: false, unique: false},
|
||||
plan_nickname: {type: 'string', maxlength: 50, nullable: false},
|
||||
|
@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route
|
||||
*/
|
||||
describe('DB version integrity', function () {
|
||||
// Only these variables should need updating
|
||||
const currentSchemaHash = '01156d65accecd6a056a6a8341e8b81f';
|
||||
const currentSchemaHash = '45337ae85129a98e4c1b551cc91790da';
|
||||
const currentFixturesHash = 'a75211a41f515202280be7cb287e101f';
|
||||
const currentSettingsHash = 'd54210758b7054e2174fd34aa2320ad7';
|
||||
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
||||
|
@ -803,6 +803,9 @@ module.exports = class MemberRepository {
|
||||
default_payment_card_last4: paymentMethod && paymentMethod.card && paymentMethod.card.last4 || null,
|
||||
stripe_price_id: subscriptionPriceData.id,
|
||||
plan_id: subscriptionPriceData.id,
|
||||
// trial start and end are returned as Stripe timestamps and need coversion
|
||||
trial_start_at: subscription.trial_start ? new Date(subscription.trial_start * 1000) : null,
|
||||
trial_end_at: subscription.trial_end ? new Date(subscription.trial_end * 1000) : null,
|
||||
// NOTE: Defaulting to interval as migration to nullable field
|
||||
// turned out to be much bigger problem.
|
||||
// Ideally, would need nickname field to be nullable on the DB level
|
||||
@ -1371,4 +1374,3 @@ module.exports = class MemberRepository {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user