-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backfilled missing offer redemptions #20647
Backfilled missing offer redemptions #20647
Conversation
It looks like this PR contains a migration 👀 General requirements
Schema changesN/A Data changes
|
f4981c3
to
d0dd82e
Compare
.../core/server/data/migrations/versions/5.89/2024-07-30-19-51-06-backfill-offer-redemptions.js
Outdated
Show resolved
Hide resolved
.../core/server/data/migrations/versions/5.89/2024-07-30-19-51-06-backfill-offer-redemptions.js
Outdated
Show resolved
Hide resolved
if (rows && rows.length > 0) { | ||
logging.info(`Backfilling ${rows.length} offer redemptions`); | ||
// Generate IDs for each row | ||
const offerRedemptions = rows.map((row) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daniellockyer as someone who has seen a lot of these go by, do you have any concerns with this loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my own due diligence, I did a search and found this is a pretty common pattern in migrations, specifically for generating object IDs. I checked a couple of them, and did a search in Slack for their rollout and haven't found any drama.
Also tested on staging with 40k+ redemptions to backfill (max in production will be ~4k) and it completed in <3 seconds
.../core/server/data/migrations/versions/5.89/2024-07-30-19-51-06-backfill-offer-redemptions.js
Outdated
Show resolved
Hide resolved
.../core/server/data/migrations/versions/5.89/2024-07-30-19-51-06-backfill-offer-redemptions.js
Show resolved
Hide resolved
ed6774c
to
e953489
Compare
ref https://linear.app/tryghost/issue/ENG-1440/backfill-offer-redemption-data-with-a-migration ref TryGhost@bf895e6 There was a bug that caused offer redemptions to not be recorded in the database for some subscriptions that were created with an offer. The bug was fixed in the references commit above. This commit backfills the missing redemptions, based on the subscriptions that have an `offer_id` but no corresponding offer redemptions.
e953489
to
d946577
Compare
ref https://linear.app/tryghost/issue/ENG-1440/backfill-offer-redemption-data-with-a-migration
There was a bug that caused offer redemptions to not be recorded in the database for some subscriptions that were created with an offer. However, we still have the
offer_id
attached to the subscriptions, so we are able to backfill the missing redemptions. The bug was fixed in bf895e6This commit only contains a migration, which queries for subscriptions that have an
offer_id
but do not have any offer redemptions recorded, and adds any missing redemptions to theoffer_redemptions
table.