Persist gift subscription delivery data - #29849
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe PR adds gift delivery, recipient, scheduling, retry, provider tracking, and delivery outcome fields. It updates database migrations, schema indexes, TypeScript schemas, gift construction, model defaults, and database codecs. It also adds delivery terminology and updates the schema integrity hash. Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
It looks like this PR contains a migration 👀 General requirements
Schema changes
Data changes
|
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run ghost:test:ci:integration |
✅ Succeeded | 3m 4s | View ↗ |
nx run ghost:test:integration |
✅ Succeeded | 3m 13s | View ↗ |
nx run ghost:test:legacy |
✅ Succeeded | 2m 51s | View ↗ |
nx run ghost:test:e2e |
✅ Succeeded | 2m 47s | View ↗ |
nx run-many -t test:unit -p ghost |
✅ Succeeded | 32s | View ↗ |
nx run ghost-monorepo:lint:boundaries |
✅ Succeeded | 21s | View ↗ |
nx run-many -t lint -p ghost,ghost-monorepo |
✅ Succeeded | 18s | View ↗ |
nx run @tryghost/admin:build |
✅ Succeeded | 8s | View ↗ |
nx run-many --target=build --projects=tag:publi... |
✅ Succeeded | <1s | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-08-11 16:55:24 UTC
133ccca to
d4dc1d9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 133ccca423
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #29849 +/- ##
==========================================
- Coverage 75.47% 75.38% -0.10%
==========================================
Files 1606 1610 +4
Lines 140753 140938 +185
Branches 17458 17455 -3
==========================================
+ Hits 106237 106247 +10
- Misses 33439 33613 +174
- Partials 1077 1078 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
d4dc1d9 to
09af726
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ghost/core/core/server/services/gifts/gift.ts`:
- Around line 149-162: Update checkRedeemable() to reject gifts whose deliverAt
is in the future before applying the existing redemption checks, while allowing
past and current delivery dates. Return a distinct non-redeemable reason for
delayed availability, and add tests covering past, current, and future deliverAt
values.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 24204e7f-0bc1-46e5-8b44-c9d77f61d794
📒 Files selected for processing (9)
ghost/core/core/server/data/migrations/versions/6.57/2026-08-05-15-03-16-add-gift-delivery-fields.jsghost/core/core/server/data/migrations/versions/6.57/2026-08-05-15-15-28-add-gifts-email-provider-message-id-index.jsghost/core/core/server/data/schema/schema.jsghost/core/core/server/models/gift.jsghost/core/core/server/services/gifts/CONTEXT.mdghost/core/core/server/services/gifts/gift-codec.tsghost/core/core/server/services/gifts/gift-schema.tsghost/core/core/server/services/gifts/gift.tsghost/core/test/unit/server/data/schema/integrity.test.js
7368ac9 to
f3e4da1
Compare
ref https://linear.app/ghost/issue/BER-3851/establish-immediate-email-delivery-for-gift-subscriptions Gift subscriptions need one authoritative delivery snapshot on the gift before transport, scheduling, and checkout behavior can be introduced independently.
ref https://linear.app/ghost/issue/BER-3851/establish-immediate-email-delivery-for-gift-subscriptions The 6.57 migration folder has already shipped, so newly added migrations must target the next minor to run for existing installations.
ref https://linear.app/ghost/issue/BER-3851/establish-immediate-email-delivery-for-gift-subscriptions The field stores a provider failure payload rather than general diagnostics, so the narrower error name matches its actual contract and existing terminology.
ref https://linear.app/ghost/issue/BER-3851/establish-immediate-email-delivery-for-gift-subscriptions SetOptional expresses the constructor's defaulted fields directly and avoids maintaining the same key list in both Omit and Partial Pick.
ref https://linear.app/ghost/issue/BER-3851/establish-immediate-email-delivery-for-gift-subscriptions Gift.fromPurchase can rely on the constructor's delivery defaults, leaving only the lifecycle state that is specific to a new purchase.
ref https://linear.app/ghost/issue/BER-3851/establish-immediate-email-delivery-for-gift-subscriptions Constructor and purchase inputs should inherit optional fields from Zod defaults instead of maintaining separate property lists that can drift from the schema.
ref https://linear.app/ghost/issue/BER-3851/establish-immediate-email-delivery-for-gift-subscriptions Gift delivery and redemption have independent lifecycles, so email-only transport state now lives in a one-to-one delivery record while availability remains part of the gift entitlement.
f3e4da1 to
dcb0dbd
Compare

ref https://linear.app/ghost/issue/BER-3851/
Summary
Stack
2 of 6. Stacked on #29848; the transactional email transport PR is next.