Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughA new database table named 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
It looks like this PR contains a migration 👀 General requirements
Schema changes
Data changes
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ghost/core/core/server/data/schema/schema.js (1)
1173-1207: Consider adding anupdated_atcolumn for tracking modifications.Most tables in the schema include
created_atandupdated_atcolumns (e.g.,offers,products,subscriptions). Whilepurchased_atserves as the creation timestamp, there's no column to track subsequent modifications to gift records (e.g., status changes, redemption updates).If gifts are immutable after purchase, this is fine. Otherwise, consider adding:
consumed_at: {type: 'dateTime', nullable: true} + created_at: {type: 'dateTime', nullable: false}, + updated_at: {type: 'dateTime', nullable: true} }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ghost/core/core/server/data/schema/schema.js` around lines 1173 - 1207, The gifts schema is missing an updated_at column to track modifications; add an updated_at field to the gifts table definition (alongside the existing purchased_at, redeemed_at, etc.) with the same type and nullability pattern used elsewhere (e.g., type 'dateTime', nullable: true) so updates to records such as status changes or redemption timestamps can be recorded; update any migration or model logic that expects timestamps to include this new updated_at field where necessary.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ghost/core/core/server/data/schema/schema.js`:
- Around line 1173-1207: The gifts schema is missing an updated_at column to
track modifications; add an updated_at field to the gifts table definition
(alongside the existing purchased_at, redeemed_at, etc.) with the same type and
nullability pattern used elsewhere (e.g., type 'dateTime', nullable: true) so
updates to records such as status changes or redemption timestamps can be
recorded; update any migration or model logic that expects timestamps to include
this new updated_at field where necessary.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 861d70a6-a191-4e9a-b974-39298c11f4f9
📒 Files selected for processing (3)
ghost/core/core/server/data/migrations/versions/6.23/2026-03-26-16-41-06-add-gifts-table.jsghost/core/core/server/data/schema/schema.jsghost/core/test/unit/server/data/schema/integrity.test.js
| duration: {type: 'integer', nullable: false, unsigned: true}, | ||
|
|
||
| currency: {type: 'string', maxlength: 50, nullable: false}, | ||
| amount: {type: 'integer', nullable: false}, |
There was a problem hiding this comment.
Yep good shout, updated
There was a problem hiding this comment.
🧹 Nitpick comments (2)
ghost/core/core/server/data/schema/schema.js (2)
1173-1207: Consider adding anupdated_atfield for consistency and auditability.Most tables in this schema include an
updated_at: {type: 'dateTime', nullable: true}field to track when records are modified. Thegiftstable will likely have status transitions (purchased → redeemed → consumed, or purchased → expired, etc.), and havingupdated_athelps track when these changes occur for debugging and auditing purposes.Proposed fix
refunded_at: {type: 'dateTime', nullable: true}, - consumed_at: {type: 'dateTime', nullable: true} + consumed_at: {type: 'dateTime', nullable: true}, + updated_at: {type: 'dateTime', nullable: true} }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ghost/core/core/server/data/schema/schema.js` around lines 1173 - 1207, Add an updated_at column to the gifts table schema to match other tables and record modification timestamps: inside the gifts schema object (adjacent to fields like purchased_at, redeemed_at, status), add an updated_at: {type: 'dateTime', nullable: true} entry so updates to status (purchased/redeemed/consumed/expired/refunded) and other changes are auditable and consistent with existing tables.
1197-1206: Consider adding indexes for common query patterns.Depending on expected query patterns, you may want to add indexes on frequently queried columns like
status,buyer_member_id,redeemer_member_id, ortier_id. This can be deferred until actual usage patterns are known.Example index definition
'@@INDEXES@@': [ ['status'], ['buyer_member_id'], ['tier_id'] ]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ghost/core/core/server/data/schema/schema.js` around lines 1197 - 1206, The schema for the vouchers table lacks indexes for columns likely used in filters (e.g., status, buyer_member_id, redeemer_member_id, tier_id); add an '@@INDEXES@@' entry to the schema definition (near the fields status, purchased_at, redeemed_at, etc.) listing arrays for the columns you expect to query frequently (for example ['status'], ['buyer_member_id'], ['tier_id'], and optionally ['redeemer_member_id']) so the ORM/DB will create those indexes; keep index names/defaults consistent with existing schema conventions when adding the '@@INDEXES@@' block.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ghost/core/core/server/data/schema/schema.js`:
- Around line 1173-1207: Add an updated_at column to the gifts table schema to
match other tables and record modification timestamps: inside the gifts schema
object (adjacent to fields like purchased_at, redeemed_at, status), add an
updated_at: {type: 'dateTime', nullable: true} entry so updates to status
(purchased/redeemed/consumed/expired/refunded) and other changes are auditable
and consistent with existing tables.
- Around line 1197-1206: The schema for the vouchers table lacks indexes for
columns likely used in filters (e.g., status, buyer_member_id,
redeemer_member_id, tier_id); add an '@@INDEXES@@' entry to the schema
definition (near the fields status, purchased_at, redeemed_at, etc.) listing
arrays for the columns you expect to query frequently (for example ['status'],
['buyer_member_id'], ['tier_id'], and optionally ['redeemer_member_id']) so the
ORM/DB will create those indexes; keep index names/defaults consistent with
existing schema conventions when adding the '@@INDEXES@@' block.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e1cabf00-5cee-48d3-a893-52e032394b50
📒 Files selected for processing (4)
ghost/core/core/server/data/exporter/table-lists.jsghost/core/core/server/data/migrations/versions/6.23/2026-03-26-16-41-06-add-gifts-table.jsghost/core/core/server/data/schema/schema.jsghost/core/test/unit/server/data/schema/integrity.test.js
✅ Files skipped from review due to trivial changes (3)
- ghost/core/core/server/data/exporter/table-lists.js
- ghost/core/core/server/data/migrations/versions/6.23/2026-03-26-16-41-06-add-gifts-table.js
- ghost/core/test/unit/server/data/schema/integrity.test.js
closes https://linear.app/ghost/issue/BER-3502 ref https://linear.app/ghost/project/gift-subscriptions-b7184e4f8972 Adds a new table in the context of the gift subscriptions project, to store gift data (buyer info, redeemer info, gift amount/currency/duration, etc.)
|



closes https://linear.app/ghost/issue/BER-3502
ref https://linear.app/ghost/project/gift-subscriptions-b7184e4f8972
Adding a new table in the context of the gift subscriptions project, to store gift data (buyer info, redeemer info, gift amount/currency/duration, etc.)