stack/apps/backend/prisma/migrations
Konsti Wohlwend 8a77e07f19
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Emulator Test / docker (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Test / docker (push) Has been cancelled
Runs E2E API Tests / build (22.x) (push) Has been cancelled
Runs E2E API Tests with external source of truth / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
Rename offer to product, offer group to product catalog (#914)
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->

<!-- RECURSEML_SUMMARY:START -->
## High-level PR Summary
This PR implements a comprehensive renaming of "offer" to "product" and
"offer group" to "product catalog" throughout the codebase. The changes
include database migrations, schema updates, API compatibility layers,
function renames, and updates to client and server implementations.
Backwards compatibility is maintained through migration layers that
handle requests using the old terminology, translating them to the new
terminology before processing. The PR includes documentation of this
approach in CLAUDE-KNOWLEDGE.md. This rename affects multiple parts of
the system including the database schema, API endpoints, error types,
and SDK interfaces.

⏱️ Estimated Review Time: 1-3 hours

<details>
<summary>💡 Review Order Suggestion</summary>

| Order | File Path |
|-------|-----------|
| 1 |
`apps/backend/prisma/migrations/20250923191615_rename_offers_to_products/migration.sql`
|
| 2 |
`apps/backend/src/app/api/migrations/v2beta1/payments/purchases/offers-compat.ts`
|
| 3 |
`apps/backend/src/app/api/migrations/v2beta1/payments/purchases/create-purchase-url/route.ts`
|
| 4 |
`apps/backend/src/app/api/migrations/v2beta1/payments/purchases/validate-code/route.ts`
|
| 5 | `apps/backend/src/lib/payments.tsx` |
| 6 | `.claude/CLAUDE-KNOWLEDGE.md` |
| 7 | `packages/stack-shared/src/schema-fields.ts` |
| 8 | `packages/stack-shared/src/known-errors.tsx` |
| 9 | `packages/stack-shared/src/config/schema.ts` |
| 10 | `packages/template/src/lib/stack-app/customers/index.ts` |
| 11 |
`packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts`
|
| 12 |
`packages/template/src/lib/stack-app/apps/implementations/server-app-impl.ts`
|
</details>



[![Need help? Join our
Discord](https://img.shields.io/badge/Need%20help%3F%20Join%20our%20Discord-5865F2?style=plastic&logo=discord&logoColor=white)](https://discord.gg/n3SsVDAW6U)

<!-- RECURSEML_SUMMARY:END -->
<!-- ELLIPSIS_HIDDEN -->


----

> [!IMPORTANT]
> Renames 'offer' to 'product' and 'offer group' to 'product catalog'
across the codebase, updating database schema, API endpoints, and
application logic for consistency and backward compatibility.
> 
>   - **Database**:
> - Rename columns `offer` to `product` and `offerId` to `productId` in
`OneTimePurchase` and `Subscription` tables in `migration.sql`.
>   - **API & Migrations**:
> - Update API endpoints to accept `product_id`/`product_inline` instead
of `offer_id`/`offer_inline`.
> - Add `v2beta5` compatibility layer to map legacy `offer` fields to
`product` equivalents.
>   - **Shared Schemas**:
> - Rename `offerSchema` to `productSchema` and related schemas in
`schema-fields.ts`.
>   - **Server Implementation**:
> - Update `createCheckoutUrl` method in `server-app-impl.ts` to use
`productId`/`InlineProduct`.
>   - **Tests**:
> - Update tests to reflect renaming in `backend-helpers.ts` and other
test files.
>   - **Miscellaneous**:
>     - Remove dummy data related to offers in `dummy-data.tsx`.
> - Update documentation and comments to reflect terminology changes.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for e3227bcbd2. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>

----


<!-- ELLIPSIS_HIDDEN -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Backwards-compatibility: legacy offer_id/offer_inline requests are
accepted, normalized, and routed to product-based handlers.

* **Refactor**
* Global rename from Offer/Group → Product/Catalog across UI, APIs,
types, client/server interfaces, and error codes.

* **Bug Fixes**
* Responses, webhooks and UI consistently surface product_display_name
and product-related metadata.

* **Documentation**
* Migration notes and docs updated to explain compatibility and
parameter changes.

* **Tests**
  * Unit and E2E suites updated to cover product/catalog flows.

* **Chores**
  * Database schema migration, seed and config updates applied.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Renames offers→products and groups→catalogs end-to-end (DB, APIs,
schemas, UI, SDK, docs), adding v2beta5 compatibility to accept legacy
offer fields while updating all internals.
> 
> - **Backend/DB**:
> - Prisma migration: rename `offer`/`offerId`→`product`/`productId` in
`OneTimePurchase` and `Subscription`.
> - Update Stripe webhook, purchase-session, and internal test-mode
flows to use `product*` metadata/fields.
> - **API & Migrations**:
>   - Latest endpoints now accept `product_id`/`product_inline`.
> - Add `v2beta5` compat layer mapping legacy `offer_id`/`offer_inline`
to product equivalents; responses alias conflicting products.
> - **Shared Schemas/Errors/Config**:
> - `offerSchema`→`productSchema`,
`inlineOfferSchema`→`inlineProductSchema`, prices/types renamed.
>   - KnownErrors renamed (e.g., `PRODUCT_DOES_NOT_EXIST`).
> - Config: `groups`→`catalogs`, defaults/migrations updated; improved
override validation messages; ID regex loosened; formatter tweaks; add
schema fuzzer tests.
> - **Payments Lib**:
> - Rename APIs and logic (`offers`→`products`, `groupId`→`catalogId`),
subscription and item-quantity computation updated.
> - **Dashboard/UI**:
> - Routes, dialogs, editors, tables, and code samples switched to
products/catalogs; removed offers dummy data.
> - **SDK/Template**:
> - Client/server `createCheckoutUrl` now uses
`productId`/`InlineProduct`.
> - **Tests/Docs/Utilities**:
>   - E2E and unit tests updated; add legacy (pre-rename) tests.
> - Docs and knowledge base revised; minor script tweaks (recent-first,
limits).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e6e20ecd72. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: BilalG1 <bg2002@gmail.com>
2025-10-04 02:28:28 -07:00
..
20240306152532_initial_migration Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
20240313024014_authroization_code_new_user Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
20240418090527_magic_link Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
20240507195652_team Revert migration from USER -> GLOBAL (#589) 2025-03-28 00:04:15 +01:00
20240518151916_email_config Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
20240520152704_selected_team Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
20240528090210_email_templates Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
20240529121811_spotify_oauth Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
20240608142105_oauth_access_token Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
20240610085756_outer_oauth_info Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
20240618150845_system_team_permission System team permissions (#82) 2024-06-18 19:22:23 +02:00
20240701161229_fix_selected_team_and_added_ondelete Fixed selected team DB type (#121) 2024-07-01 18:29:42 +02:00
20240702050143_verification_codes Create users & auth endpoints in backend (#85) 2024-07-01 22:42:08 -07:00
20240707043509_team_profile_image added team profile image url (#130) 2024-07-07 06:58:29 +02:00
20240714031259_more_backend_endpoints Fix migration for dev instance 2024-07-14 10:27:02 -07:00
20240722004703_events Events (#142) 2024-07-21 18:31:42 -07:00
20240725161939_team_profiles Team user profile API (#150) 2024-07-26 16:06:59 -07:00
20240726225154_facebook_config_id Facebook business config id (#155) 2024-07-27 01:34:50 +02:00
20240730175523_oauth_access_token added migration file 2024-07-30 10:55:32 -07:00
20240802011240_password_reset_verification fixed password reset (#162) 2024-08-02 04:00:24 +02:00
20240804210316_team_invitation Team invitation (#171) 2024-08-10 09:45:47 -07:00
20240809231417_disable_sign_up Sign up restriction button on dashboard 2024-08-10 09:45:48 -07:00
20240810052738_multi_factor_authentication TOTP 2FA endpoints 2024-08-10 09:45:48 -07:00
20240811194548_client_team_creation Team frontend components (#178) 2024-08-12 02:11:42 +02:00
20240812013545_project_on_delete feat:Add delete project functionality in Project,Project-settings Issue Is:-No option to delete a project #111 (#127) 2024-08-12 03:46:25 +02:00
20240815125620_discord_oauth Implement Discord oauth provider (#187) 2024-08-17 20:54:42 +02:00
20240820045300_client_read_only_metadata Team metadata & client read only metadata (#196) 2024-08-20 20:39:13 +02:00
20240823172201_gitlab_oauth Add Gitlab OAuth as standard provider (#201) 2024-08-24 22:36:52 +02:00
20240830010429_event_index Last active (#215) 2024-09-01 02:28:43 +02:00
20240901224341_connected_account Remove shared Facebook (#238) 2024-09-11 02:25:18 +02:00
20240904155848_add_bitbucket_oauth add bitbucket oauth (#223) 2024-09-06 00:20:38 +02:00
20240905201445_ms_tenant Added Microsoft Tenant ID in OAuth option (#224) 2024-09-05 23:10:31 +02:00
20240909201430_project_on_delete fixed project deletion (#236) 2024-09-09 22:36:55 +02:00
20240910211533_remove_shared_facebook Auto migration (#526) 2025-07-24 02:38:37 +02:00
20240912185510_password_auth_unique_key added password auth unique key migration 2024-09-12 11:55:28 -07:00
20240912212547_linkedin_oauth Added Linkedin OAuth (#249) 2024-09-14 22:49:26 +02:00
20240914210306_apple_oauth Apple OAuth (#250) 2024-09-15 02:50:06 +02:00
20240917182207_account_deletion Added client side account deletion, team ids in user delete webhooks, and updated account setting UI design (#257) 2024-09-18 06:27:36 +02:00
20240919223009_x_and_slack_oauth remove slack oauth, allow no email in oauth 2024-09-19 16:35:17 -07:00
20240923165906_otp_attempts OTP (#263) 2024-09-24 20:02:06 +02:00
20240929194058_remove_otp_contact_channel New contact channels (#287) 2024-10-01 06:22:12 +02:00
20241007162201_legacy_jwt Project specific JWKs (#293) 2024-10-07 21:27:55 +02:00
20241013185548_remove_client_id_unique removed client id unique constraint (#299) 2024-10-13 22:29:34 +02:00
20241024234115_passkey_support Passkey support (#321) 2024-10-28 16:56:46 -07:00
20241026024655_user_sorting_indices Query/filtering with list users endpoint (#314) 2024-10-30 02:16:39 +01:00
20241116221711_geolocation_events Log geoip information with events (#344) 2024-11-17 18:07:36 +01:00
20241124163535_verification_code_handler_index Advanced team invitations 2024-11-26 17:12:57 +01:00
20241201043500_idp Identity Provider/External OAuth (#323) 2024-11-30 23:27:55 -08:00
20241207223510_neon_project_transfers Neon project provision (#358) 2024-12-08 11:44:35 -08:00
20241220033652_event_indices added index to events 2024-12-19 19:40:22 -08:00
20241223205737_remove_empty_profile_images Remove empty profile image strings from database 2024-12-23 13:08:36 -08:00
20241223225110_fill_empty_project_config_values Fix STACK-BACKEND-5K 2024-12-23 19:16:24 -08:00
20241223231022_remove_empty_team_profile_images Fix STACK-BACKEND-5K 2024-12-23 19:16:24 -08:00
20241223231023_onlyhttps_domains Fix STACK-BACKEND-5K 2024-12-23 19:16:24 -08:00
20241228033652_more_event_indices Raw project query (#382) 2024-12-28 11:47:09 -08:00
20250206063807_tenancies Tenancies (#418) 2025-02-07 22:54:04 -08:00
20250206073652_branch_event_indices Tenancies (#418) 2025-02-07 22:54:04 -08:00
20250207071519_tenancies_finalization Tenancies (#418) 2025-02-07 22:54:04 -08:00
20250214175437_create_user_indices Add several Postgres indices 2025-02-14 09:55:24 -08:00
20250221013242_sent_email_table Log emails into database (#455) 2025-02-21 10:07:18 -08:00
20250225200753_add_tenancy_cascade Add cascade to sentEmail (#463) 2025-02-25 12:14:01 -08:00
20250225200857_add_another Add cascade to sentEmail (#463) 2025-02-25 12:14:01 -08:00
20250227004548_make_project_description_non_nullable Make Project description field non-nullable (#483) 2025-02-27 11:32:29 -08:00
20250303231152_add_cli_auth Add CLI authentication endpoints (#503) 2025-03-12 18:44:33 -07:00
20250304004231_merge_oauth_methods Option for merging/blocking account creations with same email but different oauth provider (#502) 2025-03-10 21:25:12 +00:00
20250304200822_add_project_user_count Auto migration (#526) 2025-07-24 02:38:37 +02:00
20250310172256_add_id_and_impersonation_field Active Sessions Page (#528) 2025-03-12 22:35:32 +01:00
20250320223454_anonymous_users Anonymous users (#566) 2025-03-20 18:24:19 -07:00
20250325235813_project_user_permissions Auto migration (#526) 2025-07-24 02:38:37 +02:00
20250327194649_api_keys Api Keys (#590) 2025-04-04 13:03:10 -07:00
20250401220515_permission_unique_constraint Permission Robustness (#591) 2025-04-02 01:12:13 +02:00
20250415175023_environment_config_override Fix migrations for schemas other than public 2025-07-13 18:08:05 -07:00
20250425171311_remove_old_config Auto migration (#526) 2025-07-24 02:38:37 +02:00
20250501033443_remove_unnecessary_enums Source of Truth (#660) 2025-07-11 17:59:03 -07:00
20250520185503_rename_neon Refactor project integration identifiers from externalProjectId to clientId across the backend, including environment configuration, database schema, and API endpoints. Update test cases to reflect these changes for both custom and Neon integrations. 2025-05-26 13:03:30 -07:00
20250612094816_sign_in_invitation Improve user profile page (#712) 2025-07-02 02:59:12 +02:00
20250619200740_user_notification_pref Send email route and notification settings page (#717) 2025-07-01 19:17:53 -07:00
20250623074155_source_of_truth Source of Truth (#660) 2025-07-11 17:59:03 -07:00
20250624065420_project_config_override Source of Truth (#660) 2025-07-11 17:59:03 -07:00
20250624070114_remove_mirroredproject_fkey Source of Truth (#660) 2025-07-11 17:59:03 -07:00
20250710181826_tenancy_foreign_keys Source of Truth (#660) 2025-07-11 17:59:03 -07:00
20250711232750_oauth_method Fix OAuth provider migration (#793) 2025-07-23 19:19:47 +02:00
20250712011643_thread_messages Vibe coding themes (#755) 2025-07-15 12:06:50 -07:00
20250714205101_oauth_token_is_valid Making OAuth token refresh more robust (#767) 2025-07-16 23:00:22 +02:00
20250715181353_remove_msg_role Email themes UI fixes (#768) 2025-07-18 10:25:54 -07:00
20250717230045_remove_triggers Fix source of truth for custom schemas (#764) 2025-07-18 11:01:29 -07:00
20250718232921_drop_user_count drop user count 2025-07-18 16:29:31 -07:00
20250723001607_twitch Add an OAuth provider for Twitch (#728) 2025-07-23 02:31:47 +02:00
20250801204029_logo_url Project logo upload (#817) 2025-08-19 04:45:16 +02:00
20250805195319_subscriptions Payment tests, account status, smartRoutes (#828) 2025-08-08 18:13:22 -07:00
20250806171211_add_team_based_project_ownership Remove index creation from project owner migrations 2025-08-19 13:59:14 -07:00
20250809002037_item_quantity_change Payments manual items (#837) 2025-08-19 14:21:12 -07:00
20250815012830_email_drafts Email Drafts (#849) 2025-09-10 22:57:18 +00:00
20250820164831_custom_customer_types Remove customerType from ItemQuantityChange 2025-08-25 12:36:58 -07:00
20250820175830_grant_internal_users_team_admin Fix recent migration 2025-08-20 18:03:42 -07:00
20250821175509_test_mode_subscriptions creationSource default 2025-08-25 13:12:22 -07:00
20250821212828_subscription_quantity payments schema changes, ledger algo, stackable items (#862) 2025-08-27 20:13:22 +00:00
20250822203223_subscription_offer_id payments schema changes, ledger algo, stackable items (#862) 2025-08-27 20:13:22 +00:00
20250825221947_stripe_account_id payments schema changes, ledger algo, stackable items (#862) 2025-08-27 20:13:22 +00:00
20250830000849_data_vault Data vaults (#871) 2025-08-30 23:42:56 -07:00
20250831003652_session_id_event_indices Faster endpoints 2025-08-31 00:39:25 -07:00
20250903080405_workflows Workflows (#873) 2025-09-03 01:22:08 -07:00
20250911230246_one_time_purchase one time payments (#865) 2025-09-12 17:14:09 -07:00
20250917193043_store_price_id Transactions page (#900) 2025-09-20 07:01:07 +00:00
20250918005821_item_quantity_change_customer_type Transactions page (#900) 2025-09-20 07:01:07 +00:00
20250923191615_rename_offers_to_products Rename offer to product, offer group to product catalog (#914) 2025-10-04 02:28:28 -07:00
20251003231948_enable_and_pin_apps Apps backend changes 2025-10-03 23:50:07 -07:00
migration_lock.toml Source of Truth (#660) 2025-07-11 17:59:03 -07:00