-
Notifications
You must be signed in to change notification settings - Fork 484
Upgrade Prisma to v7 #1064
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
base: dev
Are you sure you want to change the base?
Upgrade Prisma to v7 #1064
Conversation
Preview Screenshots⏳ Preview screenshots are being captured... Workspace and dev browser links will appear here once the preview environment is ready. Generated by cmux preview system |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis pull request migrates the backend to Prisma 7 with configuration externalization. It renames the database connection string environment variable, creates a centralized Prisma configuration file, updates 60+ import paths from the standard Prisma client to a generated client, introduces PrismaPg adapter usage in key areas, and removes direct database URL references from the schema. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes Areas requiring extra attention:
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 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 |
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.
Pull request overview
This PR upgrades Prisma from v6 to v7, which introduces a new client generation system requiring database adapters and configuration changes. The upgrade removes the need for a separate direct database connection string by using adapters directly.
Key changes:
- Upgrade all Prisma packages from v6.12.0 to v7.0.0
- Replace
@prisma/clientimports with@/generated/prisma/client - Add new
prisma.config.tsconfiguration file - Remove
STACK_DIRECT_DATABASE_CONNECTION_STRINGenvironment variable
Reviewed changes
Copilot reviewed 64 out of 65 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updated Prisma dependencies to v7.0.0 |
| prisma/schema.prisma | Changed generator to use new client configuration with custom output path |
| prisma.config.ts | Added new Prisma v7 configuration file with datasource and migration settings |
| prisma-client.tsx | Removed global PrismaClient initialization, keeping only adapter-based clients |
| Multiple .env files | Removed STACK_DIRECT_DATABASE_CONNECTION_STRING variable references |
| Multiple source files | Updated imports from @prisma/client to @/generated/prisma/client |
| route-handlers/prisma-handler.tsx | Updated to use new Prisma runtime types and added GetResult type definition |
| oauth/model.tsx | Changed to access PrismaClientKnownRequestError through Prisma namespace |
| Auto-migration tests | Updated to use PrismaPg adapter for client instantiation |
| Scripts | Updated to use connection string with adapter pattern |
Comments suppressed due to low confidence (1)
apps/backend/src/prisma-client.tsx:1
- The removal of the global PrismaClient instance may cause issues if other parts of the codebase expect
prismaClientsStore.globalto exist. Verify that all references to this property have been updated or removed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { generateUuid } from '@stackframe/stack-shared/dist/utils/uuids'; | ||
|
|
||
| const globalPrisma = new PrismaClient(); | ||
| const globalPrisma = globalPrismaClient; |
Copilot
AI
Dec 13, 2025
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.
Creating an alias globalPrisma for globalPrismaClient is unnecessary and adds confusion. Use globalPrismaClient directly throughout the seed file for clarity.
Greptile OverviewGreptile SummaryThis PR upgrades Prisma from v6.12.0 to v7.0.0 across the backend application. The key changes include:
The migration follows Prisma v7 upgrade guidelines and maintains backward compatibility with existing database operations. Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant App as Application Code
participant Gen as Generated Prisma Client<br/>(@/generated/prisma/client)
participant Adapter as Driver Adapter<br/>(PrismaPg/PrismaNeon)
participant Config as prisma.config.ts
participant DB as PostgreSQL Database
Note over App,DB: Prisma v7 Client Initialization Flow
App->>Config: Read STACK_DATABASE_CONNECTION_STRING
Config-->>App: Connection string
App->>Adapter: Create adapter with connection string
Adapter-->>App: Driver adapter instance
App->>Gen: new PrismaClient({ adapter })
Gen-->>App: Prisma client ready
Note over App,DB: Database Query Flow
App->>Gen: Query (e.g., findMany, create)
Gen->>Adapter: Execute via driver adapter
Adapter->>DB: SQL query
DB-->>Adapter: Query results
Adapter-->>Gen: Formatted results
Gen-->>App: Typed response
|
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.
64 files reviewed, no comments
| const prismaClient = new PrismaClient(); | ||
| const connectionString = getEnvVariable("STACK_DATABASE_CONNECTION_STRING", ""); | ||
| const adapter = new PrismaPg({ connectionString }); | ||
| const prismaClient = new PrismaClient({ adapter }); |
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.
Bug: Missing schema parameter when creating PrismaPg adapter
The PrismaPg adapter is created without extracting and passing the schema parameter from the connection string. The main codebase in prisma-client.tsx uses getSchemaFromConnectionString() to extract the ?schema=xxx URL parameter and passes it to the adapter as the second argument. Without this, if the connection string specifies a non-default PostgreSQL schema, the adapter will query the wrong schema (defaulting to public). This could cause the verification script to fail or query incorrect data when running against databases that use custom schemas.
Additional Locations (1)
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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
apps/e2e/.env (1)
1-10: Env var rename looks right; consider fixing dotenv-linter key ordering.
If you want to silence[UnorderedKey], moveSTACK_DATABASE_CONNECTION_STRINGabove the internal project key block.apps/backend/src/auto-migrations/auto-migration.tests.ts (1)
9-18: Fix DB URL parsing to use proper URL API and remove trailing?in connection strings.The current code uses fragile string manipulation that can produce invalid connection strings:
.replace(/\/[^/]*$/, '')may strip the database path entirely, leaving an invalid base URL.split('?')[1]then concatenating?${dbURL.query}yields...?when there's no query stringSwitch to the
URLAPI to properly parse and reconstruct the connection string:const getTestDbURL = (testDbName: string) => { // @ts-ignore - ImportMeta.env is provided by Vite - const base = import.meta.env.STACK_DATABASE_CONNECTION_STRING.replace(/\/[^/]*$/, ''); - // @ts-ignore - ImportMeta.env is provided by Vite - const query = import.meta.env.STACK_DATABASE_CONNECTION_STRING.split('?')[1] ?? ''; + const raw = import.meta.env.STACK_DATABASE_CONNECTION_STRING as string; + const u = new URL(raw); + const query = u.search.replace(/^\?/, ''); + const base = u.toString(); // connect to the configured (existing) DB for CREATE/DROP DATABASE + const fullUrl = new URL(raw); + fullUrl.pathname = `/${testDbName}`; + const full = fullUrl.toString(); return { - full: `${base}/${testDbName}`, base, + full, query, }; }; @@ - const connectionString = `${dbURL.full}?${dbURL.query}`; - const adapter = new PrismaPg({ connectionString }); + const adapter = new PrismaPg({ connectionString: dbURL.full }); const prismaClient = new PrismaClient({ adapter });This aligns with Prisma 7's documented pattern: pass the full connection string directly to
PrismaPg({ connectionString }), not constructed via string concatenation.Also applies to: 38–43
🧹 Nitpick comments (3)
apps/backend/scripts/verify-data-integrity.ts (1)
10-12: (Recommended) Manage PrismaClient lifecycle explicitly in this script ($disconnect), ideally not at module scope.For CLI scripts, creating the client inside
main()and disconnecting in afinallyreduces risk of hanging handles and makes failures cleaner.-const adapter = new PrismaPg({ connectionString }); -const prismaClient = new PrismaClient({ adapter }); +function createPrismaClient() { + const adapter = new PrismaPg({ connectionString }); + return new PrismaClient({ adapter }); +} @@ async function main() { + const prismaClient = createPrismaClient(); + try { // ... existing logic ... + } finally { + await prismaClient.$disconnect(); + } }apps/backend/src/app/api/latest/contact-channels/crud.tsx (1)
5-13: Use a type-only import forPrismahere (it’s only used as a type).
This avoids an unnecessary runtime import if the project preserves value imports.-import { Prisma } from "@/generated/prisma/client"; +import type { Prisma } from "@/generated/prisma/client";apps/backend/src/app/api/latest/team-member-profiles/crud.tsx (1)
5-16: Preferimport type { Prisma }(type-only usage).-import { Prisma } from "@/generated/prisma/client"; +import type { Prisma } from "@/generated/prisma/client";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (64)
.github/workflows/e2e-api-tests.yaml(1 hunks).github/workflows/e2e-custom-base-port-api-tests.yaml(1 hunks).github/workflows/e2e-source-of-truth-api-tests.yaml(1 hunks)apps/backend/.env(0 hunks)apps/backend/.env.development(0 hunks)apps/backend/package.json(2 hunks)apps/backend/prisma.config.ts(1 hunks)apps/backend/prisma/schema.prisma(1 hunks)apps/backend/prisma/seed.ts(2 hunks)apps/backend/scripts/db-migrations.ts(2 hunks)apps/backend/scripts/verify-data-integrity.ts(1 hunks)apps/backend/src/app/api/latest/(api-keys)/handlers.tsx(1 hunks)apps/backend/src/app/api/latest/auth/mfa/sign-in/verification-code-handler.tsx(1 hunks)apps/backend/src/app/api/latest/auth/oauth/callback/[provider_id]/route.tsx(1 hunks)apps/backend/src/app/api/latest/auth/otp/sign-in/verification-code-handler.tsx(1 hunks)apps/backend/src/app/api/latest/auth/passkey/register/verification-code-handler.tsx(1 hunks)apps/backend/src/app/api/latest/auth/passkey/sign-in/verification-code-handler.tsx(1 hunks)apps/backend/src/app/api/latest/auth/password/reset/verification-code-handler.tsx(1 hunks)apps/backend/src/app/api/latest/auth/sessions/crud.tsx(1 hunks)apps/backend/src/app/api/latest/auth/sessions/current/route.tsx(1 hunks)apps/backend/src/app/api/latest/contact-channels/crud.tsx(1 hunks)apps/backend/src/app/api/latest/contact-channels/verify/verification-code-handler.tsx(1 hunks)apps/backend/src/app/api/latest/emails/unsubscribe-link/route.tsx(1 hunks)apps/backend/src/app/api/latest/emails/unsubscribe-link/verification-handler.tsx(1 hunks)apps/backend/src/app/api/latest/integrations/custom/projects/transfer/confirm/verification-code-handler.tsx(1 hunks)apps/backend/src/app/api/latest/integrations/idp.ts(1 hunks)apps/backend/src/app/api/latest/integrations/neon/projects/transfer/confirm/verification-code-handler.tsx(1 hunks)apps/backend/src/app/api/latest/internal/emails/crud.tsx(1 hunks)apps/backend/src/app/api/latest/internal/metrics/route.tsx(1 hunks)apps/backend/src/app/api/latest/internal/payments/transactions/refund/route.tsx(1 hunks)apps/backend/src/app/api/latest/internal/payments/transactions/route.tsx(1 hunks)apps/backend/src/app/api/latest/internal/payments/transactions/transaction-builder.ts(1 hunks)apps/backend/src/app/api/latest/payments/purchases/create-purchase-url/route.ts(1 hunks)apps/backend/src/app/api/latest/payments/purchases/purchase-session/route.tsx(1 hunks)apps/backend/src/app/api/latest/payments/purchases/verification-code-handler.tsx(1 hunks)apps/backend/src/app/api/latest/team-invitations/accept/verification-code-handler.tsx(1 hunks)apps/backend/src/app/api/latest/team-member-profiles/crud.tsx(1 hunks)apps/backend/src/app/api/latest/teams/crud.tsx(1 hunks)apps/backend/src/app/api/latest/users/crud.tsx(1 hunks)apps/backend/src/auto-migrations/auto-migration.tests.ts(3 hunks)apps/backend/src/auto-migrations/index.tsx(1 hunks)apps/backend/src/lib/cache.tsx(1 hunks)apps/backend/src/lib/config.tsx(1 hunks)apps/backend/src/lib/contact-channel.tsx(1 hunks)apps/backend/src/lib/email-delivery-stats.tsx(1 hunks)apps/backend/src/lib/email-drafts.tsx(1 hunks)apps/backend/src/lib/email-queue-step.tsx(1 hunks)apps/backend/src/lib/emails.tsx(1 hunks)apps/backend/src/lib/internal-api-keys.tsx(1 hunks)apps/backend/src/lib/payments.tsx(1 hunks)apps/backend/src/lib/projects.tsx(1 hunks)apps/backend/src/lib/request-checks.tsx(1 hunks)apps/backend/src/lib/stripe.tsx(1 hunks)apps/backend/src/lib/tenancies.tsx(1 hunks)apps/backend/src/lib/types.tsx(1 hunks)apps/backend/src/oauth/model.tsx(1 hunks)apps/backend/src/prisma-client.tsx(1 hunks)apps/backend/src/route-handlers/prisma-handler.tsx(1 hunks)apps/backend/src/route-handlers/verification-code-handler.tsx(1 hunks)apps/e2e/.env(1 hunks)apps/e2e/.env.development(1 hunks)docker/emulator/docker.compose.yaml(0 hunks)docker/server/.env(1 hunks)docker/server/.env.example(0 hunks)
💤 Files with no reviewable changes (4)
- apps/backend/.env
- apps/backend/.env.development
- docker/emulator/docker.compose.yaml
- docker/server/.env.example
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Always add new E2E tests when changing the API or SDK interface
For blocking alerts and errors, never use toast; use alerts instead as they are less easily missed by the user
NEVER try-catch-all, NEVER void a promise, and NEVER .catch(console.error); use loading indicators and async callbacks instead, or use runAsynchronously/runAsynchronouslyWithAlert for error handling
Use ES6 maps instead of records wherever you can
Files:
apps/backend/src/auto-migrations/index.tsxapps/backend/src/app/api/latest/integrations/custom/projects/transfer/confirm/verification-code-handler.tsxapps/backend/src/app/api/latest/(api-keys)/handlers.tsxapps/backend/src/lib/request-checks.tsxapps/backend/src/app/api/latest/payments/purchases/purchase-session/route.tsxapps/backend/src/lib/types.tsxapps/backend/src/oauth/model.tsxapps/backend/src/app/api/latest/emails/unsubscribe-link/route.tsxapps/backend/src/app/api/latest/internal/payments/transactions/route.tsxapps/backend/src/lib/internal-api-keys.tsxapps/backend/src/app/api/latest/auth/sessions/crud.tsxapps/backend/src/app/api/latest/auth/sessions/current/route.tsxapps/backend/src/app/api/latest/contact-channels/verify/verification-code-handler.tsxapps/backend/scripts/db-migrations.tsapps/backend/src/lib/contact-channel.tsxapps/backend/src/lib/payments.tsxapps/backend/src/app/api/latest/payments/purchases/verification-code-handler.tsxapps/backend/src/lib/projects.tsxapps/backend/src/app/api/latest/team-invitations/accept/verification-code-handler.tsxapps/backend/src/app/api/latest/auth/otp/sign-in/verification-code-handler.tsxapps/backend/src/app/api/latest/payments/purchases/create-purchase-url/route.tsapps/backend/src/app/api/latest/integrations/neon/projects/transfer/confirm/verification-code-handler.tsxapps/backend/src/app/api/latest/contact-channels/crud.tsxapps/backend/src/app/api/latest/auth/passkey/register/verification-code-handler.tsxapps/backend/src/lib/cache.tsxapps/backend/src/lib/config.tsxapps/backend/src/lib/emails.tsxapps/backend/src/route-handlers/verification-code-handler.tsxapps/backend/src/app/api/latest/team-member-profiles/crud.tsxapps/backend/scripts/verify-data-integrity.tsapps/backend/src/prisma-client.tsxapps/backend/src/app/api/latest/integrations/idp.tsapps/backend/src/app/api/latest/auth/oauth/callback/[provider_id]/route.tsxapps/backend/src/app/api/latest/emails/unsubscribe-link/verification-handler.tsxapps/backend/src/app/api/latest/internal/payments/transactions/transaction-builder.tsapps/backend/src/lib/email-drafts.tsxapps/backend/src/app/api/latest/users/crud.tsxapps/backend/src/app/api/latest/auth/mfa/sign-in/verification-code-handler.tsxapps/backend/prisma/seed.tsapps/backend/src/app/api/latest/internal/emails/crud.tsxapps/backend/src/app/api/latest/teams/crud.tsxapps/backend/src/app/api/latest/internal/metrics/route.tsxapps/backend/src/app/api/latest/auth/password/reset/verification-code-handler.tsxapps/backend/src/lib/tenancies.tsxapps/backend/src/lib/stripe.tsxapps/backend/src/route-handlers/prisma-handler.tsxapps/backend/src/app/api/latest/internal/payments/transactions/refund/route.tsxapps/backend/prisma.config.tsapps/backend/src/auto-migrations/auto-migration.tests.tsapps/backend/src/lib/email-delivery-stats.tsxapps/backend/src/lib/email-queue-step.tsxapps/backend/src/app/api/latest/auth/passkey/sign-in/verification-code-handler.tsx
**/*.{ts,tsx,css}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,css}: Keep hover/click transitions snappy and fast; avoid fade-in delays on hover. Apply transitions after action completion instead, like smooth fade-out when hover ends
Use hover-exit transitions instead of hover-enter transitions; for example, use 'transition-colors hover:transition-none' instead of fade-in on hover
Files:
apps/backend/src/auto-migrations/index.tsxapps/backend/src/app/api/latest/integrations/custom/projects/transfer/confirm/verification-code-handler.tsxapps/backend/src/app/api/latest/(api-keys)/handlers.tsxapps/backend/src/lib/request-checks.tsxapps/backend/src/app/api/latest/payments/purchases/purchase-session/route.tsxapps/backend/src/lib/types.tsxapps/backend/src/oauth/model.tsxapps/backend/src/app/api/latest/emails/unsubscribe-link/route.tsxapps/backend/src/app/api/latest/internal/payments/transactions/route.tsxapps/backend/src/lib/internal-api-keys.tsxapps/backend/src/app/api/latest/auth/sessions/crud.tsxapps/backend/src/app/api/latest/auth/sessions/current/route.tsxapps/backend/src/app/api/latest/contact-channels/verify/verification-code-handler.tsxapps/backend/scripts/db-migrations.tsapps/backend/src/lib/contact-channel.tsxapps/backend/src/lib/payments.tsxapps/backend/src/app/api/latest/payments/purchases/verification-code-handler.tsxapps/backend/src/lib/projects.tsxapps/backend/src/app/api/latest/team-invitations/accept/verification-code-handler.tsxapps/backend/src/app/api/latest/auth/otp/sign-in/verification-code-handler.tsxapps/backend/src/app/api/latest/payments/purchases/create-purchase-url/route.tsapps/backend/src/app/api/latest/integrations/neon/projects/transfer/confirm/verification-code-handler.tsxapps/backend/src/app/api/latest/contact-channels/crud.tsxapps/backend/src/app/api/latest/auth/passkey/register/verification-code-handler.tsxapps/backend/src/lib/cache.tsxapps/backend/src/lib/config.tsxapps/backend/src/lib/emails.tsxapps/backend/src/route-handlers/verification-code-handler.tsxapps/backend/src/app/api/latest/team-member-profiles/crud.tsxapps/backend/scripts/verify-data-integrity.tsapps/backend/src/prisma-client.tsxapps/backend/src/app/api/latest/integrations/idp.tsapps/backend/src/app/api/latest/auth/oauth/callback/[provider_id]/route.tsxapps/backend/src/app/api/latest/emails/unsubscribe-link/verification-handler.tsxapps/backend/src/app/api/latest/internal/payments/transactions/transaction-builder.tsapps/backend/src/lib/email-drafts.tsxapps/backend/src/app/api/latest/users/crud.tsxapps/backend/src/app/api/latest/auth/mfa/sign-in/verification-code-handler.tsxapps/backend/prisma/seed.tsapps/backend/src/app/api/latest/internal/emails/crud.tsxapps/backend/src/app/api/latest/teams/crud.tsxapps/backend/src/app/api/latest/internal/metrics/route.tsxapps/backend/src/app/api/latest/auth/password/reset/verification-code-handler.tsxapps/backend/src/lib/tenancies.tsxapps/backend/src/lib/stripe.tsxapps/backend/src/route-handlers/prisma-handler.tsxapps/backend/src/app/api/latest/internal/payments/transactions/refund/route.tsxapps/backend/prisma.config.tsapps/backend/src/auto-migrations/auto-migration.tests.tsapps/backend/src/lib/email-delivery-stats.tsxapps/backend/src/lib/email-queue-step.tsxapps/backend/src/app/api/latest/auth/passkey/sign-in/verification-code-handler.tsx
apps/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
NEVER use Next.js dynamic functions if you can avoid them; prefer using client components and hooks like usePathname instead of await params to keep pages static
Files:
apps/backend/src/auto-migrations/index.tsxapps/backend/src/app/api/latest/integrations/custom/projects/transfer/confirm/verification-code-handler.tsxapps/backend/src/app/api/latest/(api-keys)/handlers.tsxapps/backend/src/lib/request-checks.tsxapps/backend/src/app/api/latest/payments/purchases/purchase-session/route.tsxapps/backend/src/lib/types.tsxapps/backend/src/oauth/model.tsxapps/backend/src/app/api/latest/emails/unsubscribe-link/route.tsxapps/backend/src/app/api/latest/internal/payments/transactions/route.tsxapps/backend/src/lib/internal-api-keys.tsxapps/backend/src/app/api/latest/auth/sessions/crud.tsxapps/backend/src/app/api/latest/auth/sessions/current/route.tsxapps/backend/src/app/api/latest/contact-channels/verify/verification-code-handler.tsxapps/backend/scripts/db-migrations.tsapps/backend/src/lib/contact-channel.tsxapps/backend/src/lib/payments.tsxapps/backend/src/app/api/latest/payments/purchases/verification-code-handler.tsxapps/backend/src/lib/projects.tsxapps/backend/src/app/api/latest/team-invitations/accept/verification-code-handler.tsxapps/backend/src/app/api/latest/auth/otp/sign-in/verification-code-handler.tsxapps/backend/src/app/api/latest/payments/purchases/create-purchase-url/route.tsapps/backend/src/app/api/latest/integrations/neon/projects/transfer/confirm/verification-code-handler.tsxapps/backend/src/app/api/latest/contact-channels/crud.tsxapps/backend/src/app/api/latest/auth/passkey/register/verification-code-handler.tsxapps/backend/src/lib/cache.tsxapps/backend/src/lib/config.tsxapps/backend/src/lib/emails.tsxapps/backend/src/route-handlers/verification-code-handler.tsxapps/backend/src/app/api/latest/team-member-profiles/crud.tsxapps/backend/scripts/verify-data-integrity.tsapps/backend/src/prisma-client.tsxapps/backend/src/app/api/latest/integrations/idp.tsapps/backend/src/app/api/latest/auth/oauth/callback/[provider_id]/route.tsxapps/backend/src/app/api/latest/emails/unsubscribe-link/verification-handler.tsxapps/backend/src/app/api/latest/internal/payments/transactions/transaction-builder.tsapps/backend/src/lib/email-drafts.tsxapps/backend/src/app/api/latest/users/crud.tsxapps/backend/src/app/api/latest/auth/mfa/sign-in/verification-code-handler.tsxapps/backend/prisma/seed.tsapps/backend/src/app/api/latest/internal/emails/crud.tsxapps/backend/src/app/api/latest/teams/crud.tsxapps/backend/src/app/api/latest/internal/metrics/route.tsxapps/backend/src/app/api/latest/auth/password/reset/verification-code-handler.tsxapps/backend/src/lib/tenancies.tsxapps/backend/src/lib/stripe.tsxapps/backend/src/route-handlers/prisma-handler.tsxapps/backend/src/app/api/latest/internal/payments/transactions/refund/route.tsxapps/backend/prisma.config.tsapps/backend/src/auto-migrations/auto-migration.tests.tsapps/backend/src/lib/email-delivery-stats.tsxapps/backend/src/lib/email-queue-step.tsxapps/backend/src/app/api/latest/auth/passkey/sign-in/verification-code-handler.tsx
{.env*,**/*.{ts,tsx,js}}
📄 CodeRabbit inference engine (AGENTS.md)
Prefix environment variables with STACK_ (or NEXT_PUBLIC_STACK_ if public) so changes are picked up by Turborepo and improves readability
Files:
apps/backend/src/auto-migrations/index.tsxapps/backend/src/app/api/latest/integrations/custom/projects/transfer/confirm/verification-code-handler.tsxapps/backend/src/app/api/latest/(api-keys)/handlers.tsxapps/backend/src/lib/request-checks.tsxapps/backend/src/app/api/latest/payments/purchases/purchase-session/route.tsxapps/backend/src/lib/types.tsxapps/backend/src/oauth/model.tsxapps/backend/src/app/api/latest/emails/unsubscribe-link/route.tsxapps/backend/src/app/api/latest/internal/payments/transactions/route.tsxapps/backend/src/lib/internal-api-keys.tsxapps/backend/src/app/api/latest/auth/sessions/crud.tsxapps/backend/src/app/api/latest/auth/sessions/current/route.tsxapps/backend/src/app/api/latest/contact-channels/verify/verification-code-handler.tsxapps/backend/scripts/db-migrations.tsapps/backend/src/lib/contact-channel.tsxapps/backend/src/lib/payments.tsxapps/backend/src/app/api/latest/payments/purchases/verification-code-handler.tsxapps/backend/src/lib/projects.tsxapps/backend/src/app/api/latest/team-invitations/accept/verification-code-handler.tsxapps/backend/src/app/api/latest/auth/otp/sign-in/verification-code-handler.tsxapps/backend/src/app/api/latest/payments/purchases/create-purchase-url/route.tsapps/backend/src/app/api/latest/integrations/neon/projects/transfer/confirm/verification-code-handler.tsxapps/backend/src/app/api/latest/contact-channels/crud.tsxapps/backend/src/app/api/latest/auth/passkey/register/verification-code-handler.tsxapps/backend/src/lib/cache.tsxapps/backend/src/lib/config.tsxapps/backend/src/lib/emails.tsxapps/backend/src/route-handlers/verification-code-handler.tsxapps/backend/src/app/api/latest/team-member-profiles/crud.tsxapps/backend/scripts/verify-data-integrity.tsapps/backend/src/prisma-client.tsxapps/backend/src/app/api/latest/integrations/idp.tsapps/backend/src/app/api/latest/auth/oauth/callback/[provider_id]/route.tsxapps/backend/src/app/api/latest/emails/unsubscribe-link/verification-handler.tsxapps/backend/src/app/api/latest/internal/payments/transactions/transaction-builder.tsapps/backend/src/lib/email-drafts.tsxapps/backend/src/app/api/latest/users/crud.tsxapps/backend/src/app/api/latest/auth/mfa/sign-in/verification-code-handler.tsxapps/backend/prisma/seed.tsapps/backend/src/app/api/latest/internal/emails/crud.tsxapps/backend/src/app/api/latest/teams/crud.tsxapps/backend/src/app/api/latest/internal/metrics/route.tsxapps/backend/src/app/api/latest/auth/password/reset/verification-code-handler.tsxapps/backend/src/lib/tenancies.tsxapps/backend/src/lib/stripe.tsxapps/backend/src/route-handlers/prisma-handler.tsxapps/backend/src/app/api/latest/internal/payments/transactions/refund/route.tsxapps/backend/prisma.config.tsapps/backend/src/auto-migrations/auto-migration.tests.tsapps/backend/src/lib/email-delivery-stats.tsxapps/backend/src/lib/email-queue-step.tsxapps/backend/src/app/api/latest/auth/passkey/sign-in/verification-code-handler.tsx
apps/**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Check existing apps for inspiration when implementing new apps or pages; update apps-frontend.tsx and apps-config.ts to add new apps
Files:
apps/backend/src/auto-migrations/index.tsxapps/backend/src/app/api/latest/integrations/custom/projects/transfer/confirm/verification-code-handler.tsxapps/backend/src/app/api/latest/(api-keys)/handlers.tsxapps/backend/src/lib/request-checks.tsxapps/backend/src/app/api/latest/payments/purchases/purchase-session/route.tsxapps/backend/src/lib/types.tsxapps/backend/src/oauth/model.tsxapps/backend/src/app/api/latest/emails/unsubscribe-link/route.tsxapps/backend/src/app/api/latest/internal/payments/transactions/route.tsxapps/backend/src/lib/internal-api-keys.tsxapps/backend/src/app/api/latest/auth/sessions/crud.tsxapps/backend/src/app/api/latest/auth/sessions/current/route.tsxapps/backend/src/app/api/latest/contact-channels/verify/verification-code-handler.tsxapps/backend/src/lib/contact-channel.tsxapps/backend/src/lib/payments.tsxapps/backend/src/app/api/latest/payments/purchases/verification-code-handler.tsxapps/backend/src/lib/projects.tsxapps/backend/src/app/api/latest/team-invitations/accept/verification-code-handler.tsxapps/backend/src/app/api/latest/auth/otp/sign-in/verification-code-handler.tsxapps/backend/src/app/api/latest/integrations/neon/projects/transfer/confirm/verification-code-handler.tsxapps/backend/src/app/api/latest/contact-channels/crud.tsxapps/backend/src/app/api/latest/auth/passkey/register/verification-code-handler.tsxapps/backend/src/lib/cache.tsxapps/backend/src/lib/config.tsxapps/backend/src/lib/emails.tsxapps/backend/src/route-handlers/verification-code-handler.tsxapps/backend/src/app/api/latest/team-member-profiles/crud.tsxapps/backend/src/prisma-client.tsxapps/backend/src/app/api/latest/auth/oauth/callback/[provider_id]/route.tsxapps/backend/src/app/api/latest/emails/unsubscribe-link/verification-handler.tsxapps/backend/src/lib/email-drafts.tsxapps/backend/src/app/api/latest/users/crud.tsxapps/backend/src/app/api/latest/auth/mfa/sign-in/verification-code-handler.tsxapps/backend/src/app/api/latest/internal/emails/crud.tsxapps/backend/src/app/api/latest/teams/crud.tsxapps/backend/src/app/api/latest/internal/metrics/route.tsxapps/backend/src/app/api/latest/auth/password/reset/verification-code-handler.tsxapps/backend/src/lib/tenancies.tsxapps/backend/src/lib/stripe.tsxapps/backend/src/route-handlers/prisma-handler.tsxapps/backend/src/app/api/latest/internal/payments/transactions/refund/route.tsxapps/backend/src/lib/email-delivery-stats.tsxapps/backend/src/lib/email-queue-step.tsxapps/backend/src/app/api/latest/auth/passkey/sign-in/verification-code-handler.tsx
🧠 Learnings (8)
📚 Learning: 2025-12-04T18:03:49.984Z
Learnt from: CR
Repo: stack-auth/stack-auth PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-04T18:03:49.984Z
Learning: Applies to packages/stack-shared/src/config/schema.ts : Whenever making backwards-incompatible changes to the config schema, update the migration functions in packages/stack-shared/src/config/schema.ts
Applied to files:
apps/backend/src/auto-migrations/index.tsxapps/backend/src/lib/types.tsxapps/backend/src/oauth/model.tsxapps/backend/prisma/schema.prismaapps/backend/src/lib/internal-api-keys.tsxapps/backend/src/app/api/latest/auth/sessions/crud.tsxapps/backend/src/app/api/latest/auth/sessions/current/route.tsxapps/backend/scripts/db-migrations.tsapps/backend/src/lib/projects.tsxapps/backend/src/lib/cache.tsxapps/backend/src/lib/config.tsxapps/backend/scripts/verify-data-integrity.tsapps/backend/src/app/api/latest/internal/payments/transactions/transaction-builder.tsapps/backend/src/app/api/latest/users/crud.tsxapps/backend/prisma/seed.tsapps/backend/src/app/api/latest/internal/emails/crud.tsxapps/backend/src/lib/tenancies.tsxapps/backend/prisma.config.tsapps/backend/src/auto-migrations/auto-migration.tests.tsapps/backend/src/lib/email-queue-step.tsx
📚 Learning: 2025-12-03T07:19:44.433Z
Learnt from: madster456
Repo: stack-auth/stack-auth PR: 1040
File: packages/stack-shared/src/interface/crud/oauth-providers.ts:62-87
Timestamp: 2025-12-03T07:19:44.433Z
Learning: In packages/stack-shared/src/interface/crud/oauth-providers.ts and similar CRUD files, the tag "Oauth" (not "OAuth") is the correct capitalization format as it's used by the documentation generation system and follows OpenAPI conventions.
Applied to files:
apps/backend/src/lib/request-checks.tsxapps/backend/src/oauth/model.tsxapps/backend/src/app/api/latest/auth/oauth/callback/[provider_id]/route.tsx
📚 Learning: 2025-12-04T18:03:49.984Z
Learnt from: CR
Repo: stack-auth/stack-auth PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-04T18:03:49.984Z
Learning: Applies to {.env*,**/*.{ts,tsx,js}} : Prefix environment variables with STACK_ (or NEXT_PUBLIC_STACK_ if public) so changes are picked up by Turborepo and improves readability
Applied to files:
apps/backend/scripts/db-migrations.ts.github/workflows/e2e-custom-base-port-api-tests.yamlapps/e2e/.env.developmentapps/e2e/.env.github/workflows/e2e-api-tests.yaml.github/workflows/e2e-source-of-truth-api-tests.yamldocker/server/.envapps/backend/prisma.config.ts
📚 Learning: 2025-08-12T17:55:06.710Z
Learnt from: madster456
Repo: stack-auth/stack-auth PR: 769
File: apps/backend/.env:67-71
Timestamp: 2025-08-12T17:55:06.710Z
Learning: In the stack-auth project, .env files use inline comments after the = sign (e.g., KEY=# description) as a consistent pattern throughout the configuration file. The maintainers prefer this format over separate comment lines above each key.
Applied to files:
apps/e2e/.env.developmentapps/e2e/.env
📚 Learning: 2025-12-04T18:03:49.984Z
Learnt from: CR
Repo: stack-auth/stack-auth PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-04T18:03:49.984Z
Learning: Applies to apps/dashboard/**/* : When making changes in the dashboard, provide the user with a deep link to the dashboard page changed, usually in the form of http://localhost:<NEXT_PUBLIC_STACK_PORT_PREFIX>01/projects/-selector-/... or using a.localhost, b.localhost, c.localhost for port prefixes 91, 92, 93
Applied to files:
apps/e2e/.env.developmentdocker/server/.env
📚 Learning: 2025-12-04T18:03:49.984Z
Learnt from: CR
Repo: stack-auth/stack-auth PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-04T18:03:49.984Z
Learning: Run pnpm install to install dependencies, pnpm test run for testing with Vitest, pnpm lint for linting (use --fix flag to auto-fix), pnpm typecheck for type checking
Applied to files:
apps/backend/package.jsonapps/backend/src/auto-migrations/auto-migration.tests.ts
📚 Learning: 2025-12-04T18:03:49.984Z
Learnt from: CR
Repo: stack-auth/stack-auth PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-04T18:03:49.984Z
Learning: Applies to **/*.{ts,tsx} : Always add new E2E tests when changing the API or SDK interface
Applied to files:
apps/backend/src/auto-migrations/auto-migration.tests.ts
📚 Learning: 2025-12-04T18:03:49.984Z
Learnt from: CR
Repo: stack-auth/stack-auth PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-04T18:03:49.984Z
Learning: Applies to apps/e2e/**/*.{ts,tsx} : Always add new E2E tests when changing API or SDK interface; err on the side of creating too many tests due to the critical nature of the industry
Applied to files:
apps/backend/src/auto-migrations/auto-migration.tests.ts
🧬 Code graph analysis (2)
apps/backend/scripts/db-migrations.ts (1)
packages/stack-shared/src/utils/env.tsx (1)
getEnvVariable(16-58)
apps/backend/scripts/verify-data-integrity.ts (1)
packages/stack-shared/src/utils/env.tsx (1)
getEnvVariable(16-58)
🪛 Checkov (3.2.334)
.github/workflows/e2e-custom-base-port-api-tests.yaml
[medium] 20-21: Basic Auth Credentials
(CKV_SECRET_4)
.github/workflows/e2e-api-tests.yaml
[medium] 20-21: Basic Auth Credentials
(CKV_SECRET_4)
🪛 dotenv-linter (4.0.0)
apps/e2e/.env.development
[warning] 7-7: [SubstitutionKey] The STACK_DATABASE_CONNECTION_STRING key is not assigned properly
(SubstitutionKey)
[warning] 7-7: [UnorderedKey] The STACK_DATABASE_CONNECTION_STRING key should go before the STACK_INTERNAL_PROJECT_ADMIN_KEY key
(UnorderedKey)
apps/e2e/.env
[warning] 8-8: [UnorderedKey] The STACK_DATABASE_CONNECTION_STRING key should go before the STACK_INTERNAL_PROJECT_ADMIN_KEY key
(UnorderedKey)
docker/server/.env
[warning] 4-4: [ValueWithoutQuotes] This value needs to be surrounded in quotes
(ValueWithoutQuotes)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
- GitHub Check: Agent
- GitHub Check: CodeQL analysis (javascript-typescript)
- GitHub Check: Vercel Agent Review
- GitHub Check: Cursor Bugbot
- GitHub Check: setup-tests
- GitHub Check: restart-dev-and-test
- GitHub Check: check_prisma_migrations (22.x)
- GitHub Check: restart-dev-and-test-with-custom-base-port
- GitHub Check: docker
- GitHub Check: all-good
- GitHub Check: build (22.x)
- GitHub Check: E2E Tests (Node 22.x, Freestyle mock)
- GitHub Check: E2E Tests (Node 22.x, Freestyle prod)
- GitHub Check: build (22.x)
- GitHub Check: lint_and_build (latest)
🔇 Additional comments (62)
apps/backend/src/app/api/latest/auth/oauth/callback/[provider_id]/route.tsx (2)
23-23: PrismaClient type annotation and operations are correct.The type annotation and all Prisma operations (findUnique, findMany, create with nested data structures) are consistent with the generated client's interface. No behavioral changes are introduced by this import update.
Also applies to: 85-85, 116-116, 155-165, 188-209, 219-226, 320-332, 392-413
8-11: No action required—import path change is consistent with@/prisma-clientmodule.The import of
PrismaClientfrom@/generated/prisma/clientis correctly sourced. The@/prisma-clientmodule has been updated to import from the same location, maintaining type consistency throughout the codebase. This is a standard Prisma v7 migration refactor that does not introduce any API or SDK interface changes, so E2E tests are not required.apps/backend/src/app/api/latest/internal/payments/transactions/refund/route.tsx (1)
7-7: No issues found with the Prisma client import change.The import path
@/generated/prisma/clientcorrectly resolves via the TypeScript path alias@/*→./src/*. The Prisma schema confirmsSubscriptionStatusenum with membercanceledis properly defined. The generated Prisma client is created during the build phase (pnpm run codegen→prisma generateoutputs tosrc/generated/prisma), and the path is correctly referenced in.gitignoreas a build artifact. Prisma v7 is in use and the enum member casing matches the schema.apps/backend/src/app/api/latest/internal/emails/crud.tsx (1)
3-3: LGTM! Import path is valid.The change correctly updates the import to use the generated Prisma client. The
@/generated/prisma/clientpath resolves toapps/backend/src/generated/prisma/clientvia the configured tsconfig path alias, which is created by theprisma generatescript configured inprisma.config.ts. The generated directory is properly excluded from version control via.gitignore.apps/backend/src/lib/contact-channel.tsx (1)
1-1: LGTM! Import path updated for Prisma v7 migration.The import path change from
@prisma/clientto@/generated/prisma/clientcorrectly aligns with the PR's objective to migrate to Prisma v7 with centralized configuration. This pattern is already established throughout the codebase (prisma-client.tsx,verification-code-handler.tsx,prisma-handler.tsx,config.tsx, etc.). TheContactChannelTypeenum will be correctly exported from the generated client during the build process.apps/backend/src/lib/emails.tsx (1)
3-3: Import path migration to generated Prisma client is correct.The update from
@prisma/clientto@/generated/prisma/clientaligns with the Prisma v7 upgrade and proper client generation setup. The enumEmailOutboxCreatedWithwith valuesDRAFTandPROGRAMMATIC_CALLis defined in the schema and will be correctly exported from the generated client path. All related imports have been updated consistently.apps/backend/src/app/api/latest/internal/payments/transactions/transaction-builder.ts (1)
1-1: LGTM. The type import path update aligns with Prisma 7's generated client pattern. The path is properly configured inprisma/schema.prisma(output = "../src/generated/prisma"), the@/alias resolves correctly, and this pattern is already used throughout the codebase. Since this is a type-only import, there's no runtime behavior change.apps/backend/src/app/api/latest/auth/sessions/current/route.tsx (1)
3-3: Import change is correct and aligns with the Prisma 7 migration.The import path change from
"@prisma/client"to"@/generated/prisma/client"is proper for the generated Prisma client setup. The generated client is created during the build step viapnpm run codegen(which runsprisma generate), and thePrismanamespace withPrismaClientKnownRequestErroris properly exported. This pattern is already used consistently throughout the codebase in 30+ files, and the error handling on line 47 will work correctly.apps/backend/src/lib/tenancies.tsx (1)
2-2: Import path update aligns with established patterns in the codebase.The change from
@prisma/clientto@/generated/prisma/clientfollows the existing import pattern used across the backend (e.g.,prisma-client.tsx,verification-code-handler.tsx,prisma-handler.tsx,oauth/model.tsx,cache.tsx). The Prisma schema explicitly configures the generated client output to../src/generated/prisma, and the Tenancy model exists in the schema, soPrisma.TenancyGetPayloadandPrisma.sqlusage on lines 25, 99, 106, and 123 are fully supported.apps/backend/src/app/api/latest/integrations/neon/projects/transfer/confirm/verification-code-handler.tsx (1)
4-4: LGTM! The import path change from@prisma/clientto@/generated/prisma/clientis correctly configured.The
@/path alias resolves to./src/per the TypeScript configuration, and the Prisma schema is correctly configured to generate the client to../src/generated/prisma. TheVerificationCodeTypeenum will be generated during the build process whenpnpm run codegenexecutes, which runs before the Next.js build step.apps/backend/src/lib/email-delivery-stats.tsx (1)
1-1: Import path change is correct and aligns with Prisma v7 migration.The change from
@prisma/clientto@/generated/prisma/clientis the correct import for Prisma v7 with a custom output directory. The generated client is produced by the build-time codegen step (pnpm run codegen-prismarunsprisma generate) and output tosrc/generated/prisma/client. This pattern is consistently used across 40+ files in the codebase, andprisma.config.tsis properly configured for Prisma v7. ThePrisma.sqltagged template used on line 47 works identically in Prisma v7.apps/backend/src/lib/internal-api-keys.tsx (1)
4-4: LGTM!Import path correctly updated to use the generated Prisma client, consistent with the Prisma v7 upgrade pattern across the codebase.
apps/backend/src/app/api/latest/users/crud.tsx (1)
13-13: LGTM!Import path correctly updated to use the generated Prisma client. All imported types (
BooleanTrue,Prisma,PrismaClient) are properly used throughout the file.apps/backend/src/lib/stripe.tsx (1)
3-3: LGTM!Import path correctly updated for
CustomerTypeenum to use the generated Prisma client.apps/backend/src/auto-migrations/index.tsx (1)
2-2: LGTM!Import path correctly updated for the auto-migrations module. The
Prismanamespace andPrismaClienttype are properly sourced from the generated client.apps/backend/src/lib/payments.tsx (1)
2-2: LGTM!Import path correctly updated for
PurchaseCreationSourceandSubscriptionStatusenums to use the generated Prisma client.apps/backend/src/lib/config.tsx (1)
1-1: LGTM!Import path correctly updated for the
Prismanamespace used in raw SQL query construction.apps/backend/src/lib/types.tsx (1)
1-3: LGTM! Import path updated correctly.The migration from
@prisma/clientto the generated client path aligns with the PR objectives for Prisma v7 upgrade.apps/backend/src/app/api/latest/contact-channels/verify/verification-code-handler.tsx (1)
5-5: LGTM! Type import migrated correctly.The import path change for
VerificationCodeTypeis consistent with the codebase-wide migration to the generated Prisma client.apps/backend/src/lib/email-drafts.tsx (1)
1-1: LGTM! Prisma imports migrated correctly.The import path update for
DraftThemeModeandPrismaClientaligns with the Prisma v7 migration strategy.apps/backend/src/app/api/latest/(api-keys)/handlers.tsx (1)
7-7: LGTM! Type import updated correctly.The
ProjectApiKeytype import now uses the generated Prisma client path, consistent with the PR-wide migration..github/workflows/e2e-custom-base-port-api-tests.yaml (1)
20-20: LGTM! Environment variable renamed correctly.The rename from
STACK_DIRECT_DATABASE_CONNECTION_STRINGtoSTACK_DATABASE_CONNECTION_STRINGis consistent with the PR-wide migration and follows the STACK_ prefix convention per coding guidelines.Note: The static analysis hint about basic auth credentials is a false positive—this is a placeholder connection string for the test environment.
apps/backend/src/app/api/latest/auth/sessions/crud.tsx (1)
4-4: LGTM! Prisma namespace import migrated correctly.The
Prismanamespace import now uses the generated client path, enabling continued use ofPrisma.sqlfor raw queries.apps/e2e/.env.development (1)
7-7: LGTM! Environment variable renamed correctly.The rename to
STACK_DATABASE_CONNECTION_STRINGis consistent with the codebase-wide migration and follows the STACK_ prefix convention.Note: The static analysis warnings are false positives—the variable substitution syntax is valid for this environment file format.
apps/backend/src/app/api/latest/internal/payments/transactions/route.tsx (1)
3-3: LGTM! Prisma namespace import migrated correctly.The
Prismanamespace import now uses the generated client path for type definitions in the pagination logic (lines 50–60), and no remaining@prisma/clientimports exist in the backend source files.apps/backend/src/app/api/latest/auth/mfa/sign-in/verification-code-handler.tsx (1)
5-5: Enum import swap is fine; ensure Prisma v7 generated client still exportsVerificationCodeType.ONE_TIME_PASSWORD.Run a backend typecheck (and Prisma generate step, if applicable) to confirm the enum export/value is unchanged under Prisma 7.
apps/backend/src/app/api/latest/internal/metrics/route.tsx (1)
5-5: Good change; this file is a heavy user ofPrisma.sql/join—please confirm Prisma v7 generated typings compile cleanly here.In particular, validate
Prisma.sql\...`+Prisma.join(...)+$queryRaw<...>(Prisma.sql`...`)` still typechecks with the generated client.apps/backend/src/app/api/latest/integrations/idp.ts (1)
2-2: LGTM; verify Prisma v7 generated client still providesPrisma.JsonNulland compatible JSON filter typings.This file depends on both
Prisma.JsonNulland JSON-path filtering—please ensure the Prisma 7 upgrade didn’t subtly change those types/exports.apps/backend/src/app/api/latest/payments/purchases/purchase-session/route.tsx (1)
6-6: Looks fine; please confirmSubscriptionStatus.canceledstill matches the generated enum in Prisma 7.A quick typecheck should catch any enum spelling/casing drift (
canceledvs other variants).apps/backend/src/lib/projects.tsx (1)
2-2: Good update; this file relies onPrisma.sqlandPrisma.ProjectGetPayload—confirm those helpers are still exported from the generated client under Prisma 7.apps/backend/src/lib/request-checks.tsx (1)
1-1: Import change is fine; please confirm Prisma 7 still generatesStandardOAuthProviderTypeas a string type compatible withLowercase<>.apps/backend/src/app/api/latest/payments/purchases/create-purchase-url/route.ts (1)
6-6: Looks good; verify Prisma 7 generated enum members still includeCustomerType.USERandCustomerType.TEAM.apps/backend/src/lib/cache.tsx (1)
1-1: Prisma import migration is correct. The import path@/generated/prisma/clientproperly resolves via tsconfig paths to./src/generated/prisma/client. The generated Prisma client is created at build time viapnpm run prisma generateduring the codegen step (run beforenext build), so it's not committed to the repository. Line 43 correctly usesPrisma.InputJsonValuefrom this generated import.apps/backend/src/lib/email-queue-step.tsx (1)
1-1: LGTM: generated Prisma client import is correct here (needs runtimePrisma.sql/Prisma.DbNull).apps/backend/src/app/api/latest/emails/unsubscribe-link/route.tsx (1)
1-4: LGTM: runtimeVerificationCodeTypeimport migrated to generated client.apps/backend/src/app/api/latest/emails/unsubscribe-link/verification-handler.tsx (1)
1-8: LGTM: generated-clientVerificationCodeTypeis correctly used as a runtime value here..github/workflows/e2e-source-of-truth-api-tests.yaml (2)
17-23: Env var rename is complete and safe.The codebase contains no remaining references to
STACK_DIRECT_DATABASE_CONNECTION_STRING, confirming the rename toSTACK_DATABASE_CONNECTION_STRINGis fully propagated. The new name aligns with repository conventions for environment variable prefixes.
28-35: Bothactions/checkout@v6andactions/setup-node@v6are valid releases and currently maintained. No CI break risk from these action tags.apps/backend/prisma/seed.ts (1)
5-20: Type alignment confirmed:globalPrismaClientcorrectly uses the same generatedPrismaClientfrom@/generated/prisma/client.The reuse of
globalPrismaClientis solid for the seed script—allPrismaClientinstances inapps/backend/src/prisma-client.tsxare instantiated from the same import source, ensuring consistency across the codebase and proper connection management.apps/backend/src/app/api/latest/auth/otp/sign-in/verification-code-handler.tsx (1)
8-8: LGTM! Import updated to use generated Prisma client.The import path change from
@prisma/clientto@/generated/prisma/clientcorrectly aligns with the Prisma v7 migration strategy.apps/backend/src/app/api/latest/team-invitations/accept/verification-code-handler.tsx (1)
7-7: LGTM! Import updated to use generated Prisma client.The import path change correctly migrates to the generated Prisma client.
apps/backend/src/app/api/latest/auth/passkey/sign-in/verification-code-handler.tsx (1)
5-5: LGTM! Import updated to use generated Prisma client.The import path change correctly aligns with the Prisma v7 migration.
docker/server/.env (1)
4-4: LGTM! Environment variable documentation updated.The removal of
STACK_DIRECT_DATABASE_CONNECTION_STRINGand retention ofSTACK_DATABASE_CONNECTION_STRINGcorrectly reflects the simplified connection string configuration in Prisma v7. Based on learnings, this follows the STACK_ prefix convention.apps/backend/src/route-handlers/verification-code-handler.tsx (1)
4-4: LGTM! Core handler updated to use generated Prisma client.The import path change from
@prisma/clientto@/generated/prisma/clientcorrectly migrates this core verification code handler. This change properly propagates to all dependent handlers.apps/backend/src/oauth/model.tsx (1)
9-10: LGTM! Prisma error type access updated for generated client.The approach of importing
Prismafrom the generated client and then accessingPrismaClientKnownRequestErrorvia the namespace correctly aligns with Prisma v7's generated client pattern. The error handling logic at line 376 remains functionally unchanged..github/workflows/e2e-api-tests.yaml (1)
20-20: Environment variable rename is complete and consistent.The rename from
STACK_DIRECT_DATABASE_CONNECTION_STRINGtoSTACK_DATABASE_CONNECTION_STRINGaligns with the Prisma v7 migration and follows the STACK_ prefix convention. No remaining references to the old variable name exist in the codebase.apps/backend/prisma/schema.prisma (1)
1-8: Prisma v7 configuration correctly implemented with proper externalization.The changes properly implement Prisma v7's configuration approach:
- Generator provider set to
"prisma-client"(v7 convention)- Output path
"../src/generated/prisma"correctly aligns with imports throughout the codebase (@/generated/prisma/client)- Datasource simplified to
provider = "postgresql"with connection string externalized toprisma.config.tsviaSTACK_DATABASE_CONNECTION_STRINGenvironment variableapps/backend/src/app/api/latest/auth/passkey/register/verification-code-handler.tsx (1)
4-4: LGTM: Import path migration to generated Prisma client.The import path change from
@prisma/clientto@/generated/prisma/clientcorrectly aligns with the Prisma 7 migration strategy.apps/backend/src/app/api/latest/payments/purchases/verification-code-handler.tsx (1)
2-2: LGTM: Consistent import path migration.The import path change aligns with the project-wide Prisma 7 migration to the generated client.
apps/backend/src/app/api/latest/integrations/custom/projects/transfer/confirm/verification-code-handler.tsx (1)
6-6: LGTM: Import path migration continues consistently.apps/backend/src/app/api/latest/auth/password/reset/verification-code-handler.tsx (1)
4-4: LGTM: Import path updated correctly.apps/backend/src/prisma-client.tsx (3)
132-137: LGTM: Proper global client initialization with error handling.The global Prisma client initialization correctly uses the Postgres adapter and provides clear error messages when the connection string is not configured.
2-4: LGTM: Proper adapter usage for Prisma 7.The addition of PrismaNeon and PrismaPg adapters with schema-aware initialization is the correct approach for Prisma 7. All adapter versions are pinned to ^7.0.0 and match the Prisma client version. The schema extraction from connection strings and adapter configuration are properly implemented, and client caching in the global store prevents unnecessary client recreation.
106-106: The environment variable rename fromSTACK_DIRECT_DATABASE_CONNECTION_STRINGtoSTACK_DATABASE_CONNECTION_STRINGis complete. No references to the old variable name remain in the codebase. The new variable is properly used across all relevant locations: Docker configurations, Prisma configuration, package.json scripts, backend scripts, and tests.apps/backend/src/route-handlers/prisma-handler.tsx (2)
1-3: LGTM: Import changes align with Prisma 7 type system.The imports correctly separate the generated client types from the runtime types, which is the recommended pattern for Prisma 7.
10-10: LGTM: GetResult type alias properly defined.The GetResult type alias correctly maps to Prisma's runtime type utilities, enabling proper type inference for Prisma operations in the CRUD handlers.
apps/backend/scripts/db-migrations.ts (2)
4-4: LGTM: Import path updated consistently.
77-77: LGTM: Environment variable usage updated consistently.The usage of
STACK_DATABASE_CONNECTION_STRINGaligns with the changes in prisma-client.tsx.apps/backend/package.json (1)
62-65: Prisma 7.0.0 upgrade is properly configured.All Prisma dependencies have been consistently upgraded to ^7.0.0 with correct migration to Prisma 7 architecture:
- Generator provider correctly set to "prisma-client" (not "prisma-client-js")
- prisma.config.ts properly configured with new Prisma 7 pattern
- PrismaClient instantiation correctly uses adapters (PrismaNeon, PrismaPg) as required by Prisma 7
- No multi-file schema issues detected
- No enum mapping breaking changes
apps/backend/prisma.config.ts (1)
1-13: Prisma v7 config verified — all paths and scripts are correctThe
prisma/configAPI, relative schema/migrations paths, anddb-seed-scriptare all correctly configured and present in the repository.apps/backend/src/app/api/latest/teams/crud.tsx (1)
7-7: Prisma import from generated client is correctly structuredThe import on line 7 follows the standard Prisma code generation pattern. The file already uses other
@/aliases successfully (lines 1–6), confirming the path alias is configured. ThePrisma.TeamGetPayload<{}>andPrisma.JsonNullusages are standard Prisma APIs that will be available from the generated client afterprisma generateruns during the build process. No changes needed.apps/backend/src/auto-migrations/auto-migration.tests.ts (1)
1-2: Import switch to generated Prisma client + PrismaPg adapter looks consistent with the PR direction.
| const connectionString = getEnvVariable("STACK_DATABASE_CONNECTION_STRING", ""); | ||
| const adapter = new PrismaPg({ connectionString }); | ||
| const prismaClient = new PrismaClient({ adapter }); |
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.
🧩 Analysis chain
🌐 Web query:
Prisma 7 @prisma/adapter-pg initialization pattern PrismaPg PrismaClient
💡 Result:
Short pattern (Prisma 7 + @prisma/adapter-pg)
-
Install
npm install @prisma/adapter-pg -
Init in code
import { PrismaClient } from '@prisma/client'
import { PrismaPg } from '@prisma/adapter-pg'const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter })
Notes
- Driver adapters do not read the URL from schema.prisma — pass the connection string (or pg options) when creating PrismaPg. [1][2]
- There are reported issues/quirks around setting a non-public PostgreSQL schema (search_path / schema parameter) when using @prisma/adapter-pg; you may need to set search_path options or the adapter's schema parameter depending on behavior/version. Test this in your environment and consult the linked issue if you rely on multiple schemas. [3]
Sources
- Prisma docs — PostgreSQL / adapter-pg usage. [1]
- Prisma docs — Database drivers & adapter usage. [2]
- GitHub issue on schema/search_path behavior with @prisma/adapter-pg. [3]
🏁 Script executed:
# First, let's examine the actual file to understand the full context
cat -n apps/backend/scripts/verify-data-integrity.ts | head -30Repository: stack-auth/stack-auth
Length of output: 1374
Don't default STACK_DATABASE_CONNECTION_STRING to ""; fail fast and validate non-empty.
Using getEnvVariable("STACK_DATABASE_CONNECTION_STRING", "") bypasses the missing-var guard and can lead to cryptic adapter/client initialization errors or unexpected behavior. In a data-integrity verification script, missing database configuration should fail immediately and loudly. Require the env var and assert it's non-empty.
-const connectionString = getEnvVariable("STACK_DATABASE_CONNECTION_STRING", "");
+const connectionString = getEnvVariable("STACK_DATABASE_CONNECTION_STRING");
+if (!connectionString.trim()) {
+ throw new Error("STACK_DATABASE_CONNECTION_STRING must be set to a non-empty Postgres connection string.");
+}
const adapter = new PrismaPg({ connectionString });
const prismaClient = new PrismaClient({ adapter });📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const connectionString = getEnvVariable("STACK_DATABASE_CONNECTION_STRING", ""); | |
| const adapter = new PrismaPg({ connectionString }); | |
| const prismaClient = new PrismaClient({ adapter }); | |
| const connectionString = getEnvVariable("STACK_DATABASE_CONNECTION_STRING"); | |
| if (!connectionString.trim()) { | |
| throw new Error("STACK_DATABASE_CONNECTION_STRING must be set to a non-empty Postgres connection string."); | |
| } | |
| const adapter = new PrismaPg({ connectionString }); | |
| const prismaClient = new PrismaClient({ adapter }); |
🤖 Prompt for AI Agents
In apps/backend/scripts/verify-data-integrity.ts around lines 10 to 12, the code
currently defaults STACK_DATABASE_CONNECTION_STRING to an empty string which
masks missing configuration; change this to require the env var and fail fast by
removing the empty-string default (or call getEnvVariable without a fallback)
and add an explicit check that the returned connectionString is non-empty,
throwing a clear error (or process.exit(1)) with a descriptive message if it is
missing so the script fails immediately rather than allowing Prisma/adapter
initialization to produce cryptic errors.
Note
Upgrades to Prisma v7, switches to the generated client and new Prisma config, replaces direct DB env with STACK_DATABASE_CONNECTION_STRING, and updates codebase, scripts, CI, and envs accordingly.
@prisma/clienttypes to generated client at@/generated/prisma/clientacross code.prisma.config.ts; updateschema.prisma(generator provider: prisma-client, customoutput, removedirectUrl).PrismaPgin tests/tools, error classes viaPrisma).^7.xinapps/backend/package.jsonand lockfile.STACK_DATABASE_CONNECTION_STRINGand supports new config.STACK_DIRECT_DATABASE_CONNECTION_STRINGwithSTACK_DATABASE_CONNECTION_STRINGin all E2E workflows.STACK_DIRECT_DATABASE_CONNECTION_STRINGfrom.env, docs, and docker; standardize onSTACK_DATABASE_CONNECTION_STRING.Written by Cursor Bugbot for commit 3b8dadb. This will update automatically on new commits. Configure here.
Summary by CodeRabbit
Release Notes
Chores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.