Skip to content

feat: Migrate Prisma from 6.14.0 to 7.7.0 with driver adapters#3391

Draft
devin-ai-integration[bot] wants to merge 4 commits intomainfrom
devin/1776273089-prisma-7-upgrade
Draft

feat: Migrate Prisma from 6.14.0 to 7.7.0 with driver adapters#3391
devin-ai-integration[bot] wants to merge 4 commits intomainfrom
devin/1776273089-prisma-7-upgrade

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot commented Apr 15, 2026

Summary

Upgrades Prisma from 6.14.0 to 7.7.0, replacing the Rust binary query engine with the new TypeScript/WASM engine-less client using @prisma/adapter-pg. This eliminates the Rust↔JS serialization overhead and the binary engine process.

What changed:

  • prisma, @prisma/client → 7.7.0; added @prisma/adapter-pg@7.7.0; @prisma/instrumentation^7.7.0
  • schema.prisma: removed url/directUrl from datasource, removed binaryTargets, removed previewFeatures = ["metrics"], added engineType = "client"
  • New prisma.config.ts for Prisma CLI (migrations) — uses engine: "classic" so the schema engine binary still works for migrations while the app uses the new client engine. Excluded from TS build via tsconfig.json.
  • db.server.ts: both writer and replica PrismaClient instances now use PrismaPg adapter with pool config passed directly to the constructor instead of URL query params. The extendQueryParams() helper is removed.
  • $metrics fully dropped: removed prisma.$metrics.prometheus() from /metrics route, deleted entire configurePrismaMetrics() (~200 LOC of OTel gauges) from tracer.server.ts
  • PrismaClientKnownRequestError import path updated: @prisma/client/runtime/library@prisma/client/runtime/client
  • All other PrismaClient instantiation sites updated to adapter pattern: testcontainers, tests/utils.ts, scripts/recover-stuck-runs.ts, benchmark producer
  • references/prisma-7 updated from 6.20.0-integration-next.87.7.0 to fix a pnpm hoisting conflict (see below)
  • Testcontainers prisma db push command updated for Prisma 7 CLI changes (see below)

Updates since last revision

  • Fixed @prisma/client-runtime-utils hoisting conflict: The references/prisma-7 project pinned @prisma/client@6.20.0-integration-next.8, which caused pnpm to hoist @prisma/client-runtime-utils@6.20.0 to the workspace root instead of @7.7.0. The generated Prisma 7 client runtime references isObjectEnumValue which only exists in the v7 package, causing TypeError: (0 , Ao.isObjectEnumValue) is not a function in tests. Fixed by updating references/prisma-7/package.json to Prisma 7.7.0.

  • Fixed testcontainers prisma db push for Prisma 7: Prisma 7 removed the --skip-generate flag from prisma db push. The old command failed silently (tinyexec swallows non-zero exits), so test databases were created without any tables — causing The table 'public.X' does not exist errors across llm-model-catalog and webapp test suites. Fixed by removing --skip-generate and adding --url to pass the connection string directly to the CLI.

Review & Testing Checklist for Human

  • Pool timeout behavior change (HIGH RISK): The old code passed DATABASE_POOL_TIMEOUT (default 60s) as Prisma's pool_timeout — a connection acquisition timeout (how long a query waits for a free connection when the pool is saturated). This env var is now unused. Both idleTimeoutMillis and connectionTimeoutMillis are set to DATABASE_CONNECTION_TIMEOUT * 1000 (default 20s). pg.Pool has no connection acquisition timeout — under high load, requests will queue indefinitely instead of failing after 60s. Decide if this is acceptable or if a wrapper/different pool library is needed.
  • $on("query") events with driver adapters: QueryPerformanceMonitor.onQuery() depends on query events with duration, params, and query fields. With the new client engine + driver adapters, these events may not fire or may have different field availability. Verify at runtime that slow query detection still works.
  • Metrics/observability gap: All prisma_* Prometheus metrics and the 18 OTel gauges are gone. Verify Grafana dashboards and alerting are updated, or accept the gap. Consider adding pg.Pool stats (pool.totalCount, pool.idleCount, pool.waitingCount) in a follow-up if needed.
  • @prisma/instrumentation v7 compatibility: Updated from ^6.14.0 to ^7.7.0. Verify OTel tracing spans are still generated when INTERNAL_OTEL_TRACE_INSTRUMENT_PRISMA_ENABLED=1.
  • $transaction retry behavior: The custom $transaction wrapper retries on P2024/P2028/P2034 error codes. These may behave differently with the new engine. Test transactional workflows.

Recommended test plan: Deploy to staging, run a representative workload, and monitor for: connection pool exhaustion (especially under load), query latency regressions, missing OTel spans from QueryPerformanceMonitor, and any new error codes from the adapter layer.

Notes

  • prisma.config.ts is excluded from the TypeScript build (tsconfig.json) because its types are only consumed by the Prisma CLI.
  • DATABASE_POOL_TIMEOUT env var is now a no-op. If you want to preserve backward-compatible behavior, this needs a follow-up to either document the change or implement acquisition timeout at a different layer.
  • The references/prisma-7 project was bumped to 7.7.0 purely to fix the hoisting conflict — it may need its own prisma.config.ts and schema updates to actually run, but that's independent of this migration.
  • The testcontainers tinyexec call does not throw on non-zero exit codes, so the --skip-generate failure was silent. Consider adding error handling to createPostgresContainer in a follow-up.

Link to Devin session: https://app.devin.ai/sessions/fe7341a644774ff9acda74a2d35fb54c
Requested by: @ericallam

devin-ai-integration bot and others added 2 commits April 15, 2026 17:28
- Bump prisma, @prisma/client to 7.7.0, add @prisma/adapter-pg
- Switch to engine-less client (engineType = 'client') with PrismaPg adapter
- Remove binaryTargets and metrics preview feature from schema.prisma
- Remove url/directUrl from datasource block (Prisma 7 requirement)
- Create prisma.config.ts for CLI tools (migrations)
- Rewrite db.server.ts to use PrismaPg adapter for writer + replica clients
- Drop $metrics: remove from metrics.ts, delete configurePrismaMetrics from tracer.server.ts
- Update PrismaClientKnownRequestError import path (runtime/library -> runtime/client)
- Update all PrismaClient instantiation sites to use adapter pattern:
  testcontainers, tests/utils.ts, scripts, benchmark producer
- Exclude prisma.config.ts from TypeScript build

Co-Authored-By: Eric Allam <eallam@icloud.com>
- Bump @prisma/instrumentation from ^6.14.0 to ^7.7.0 for Prisma 7 compatibility
- Fix DATABASE_POOL_TIMEOUT incorrectly mapped to idleTimeoutMillis (semantic mismatch)
  - pool_timeout was a connection acquisition timeout, idleTimeoutMillis is idle eviction
  - Use DATABASE_CONNECTION_TIMEOUT for idleTimeoutMillis instead (pg Pool has no
    direct acquisition timeout equivalent)

Co-Authored-By: Eric Allam <eallam@icloud.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

⚠️ No Changeset found

Latest commit: f560b7b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

devin-ai-integration bot and others added 2 commits April 15, 2026 17:50
The references/prisma-7 project had @prisma/client@6.20.0-integration-next.8
which caused @prisma/client-runtime-utils@6.20.0 to be hoisted to root
instead of @7.7.0 needed by the generated Prisma 7 client. This caused
TypeError: isObjectEnumValue is not a function at runtime.

Co-Authored-By: Eric Allam <eallam@icloud.com>
…ma 7)

Prisma 7 removed the --skip-generate flag from 'prisma db push'. This caused
the testcontainers migration command to fail silently (tinyexec swallows the
error), resulting in empty databases and 'table does not exist' errors in tests.

Also added --url flag to pass the connection string directly to the CLI,
ensuring the correct URL is used regardless of config file resolution.

Co-Authored-By: Eric Allam <eallam@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant