From a669cda6057cd19dd594b736410ace37978b3eaf Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Tue, 11 Feb 2020 14:02:40 +0800 Subject: [PATCH] Added fallback plan nickname to inteval instead of empty string no issue - On model layer in Ghost empty string is always converted to `null` for not nullable fields, which wasn't letting the value through to the database - Current solution is a stopgap to fix imports of cyclic plans without nicknames. Ideally nickname field should become nullable in the future so this logic can be simplified --- ghost/members-api/lib/stripe/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ghost/members-api/lib/stripe/index.js b/ghost/members-api/lib/stripe/index.js index 3566e53b31..043779fbdc 100644 --- a/ghost/members-api/lib/stripe/index.js +++ b/ghost/members-api/lib/stripe/index.js @@ -301,7 +301,9 @@ module.exports = class StripePaymentProcessor { default_payment_card_last4: payment && payment.card && payment.card.last4 || null, plan_id: subscription.plan.id, - plan_nickname: subscription.plan.nickname || '', // NOTE: defaulting to empty string here as migration to nullable field turned to be too much bigger problem + // 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 - condition can be simplified once this is done + plan_nickname: subscription.plan.nickname || subscription.plan.interval, plan_interval: subscription.plan.interval, plan_amount: subscription.plan.amount, plan_currency: subscription.plan.currency