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
Draft
feat: Migrate Prisma from 6.14.0 to 7.7.0 with driver adapters#3391devin-ai-integration[bot] wants to merge 4 commits intomainfrom
devin-ai-integration[bot] wants to merge 4 commits intomainfrom
Conversation
- 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>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.0schema.prisma: removedurl/directUrlfrom datasource, removedbinaryTargets, removedpreviewFeatures = ["metrics"], addedengineType = "client"prisma.config.tsfor Prisma CLI (migrations) — usesengine: "classic"so the schema engine binary still works for migrations while the app uses the new client engine. Excluded from TS build viatsconfig.json.db.server.ts: both writer and replicaPrismaClientinstances now usePrismaPgadapter with pool config passed directly to the constructor instead of URL query params. TheextendQueryParams()helper is removed.$metricsfully dropped: removedprisma.$metrics.prometheus()from/metricsroute, deleted entireconfigurePrismaMetrics()(~200 LOC of OTel gauges) fromtracer.server.tsPrismaClientKnownRequestErrorimport path updated:@prisma/client/runtime/library→@prisma/client/runtime/clientPrismaClientinstantiation sites updated to adapter pattern:testcontainers,tests/utils.ts,scripts/recover-stuck-runs.ts, benchmark producerreferences/prisma-7updated from6.20.0-integration-next.8→7.7.0to fix a pnpm hoisting conflict (see below)prisma db pushcommand updated for Prisma 7 CLI changes (see below)Updates since last revision
Fixed
@prisma/client-runtime-utilshoisting conflict: Thereferences/prisma-7project pinned@prisma/client@6.20.0-integration-next.8, which caused pnpm to hoist@prisma/client-runtime-utils@6.20.0to the workspace root instead of@7.7.0. The generated Prisma 7 client runtime referencesisObjectEnumValuewhich only exists in the v7 package, causingTypeError: (0 , Ao.isObjectEnumValue) is not a functionin tests. Fixed by updatingreferences/prisma-7/package.jsonto Prisma 7.7.0.Fixed testcontainers
prisma db pushfor Prisma 7: Prisma 7 removed the--skip-generateflag fromprisma db push. The old command failed silently (tinyexecswallows non-zero exits), so test databases were created without any tables — causingThe table 'public.X' does not existerrors acrossllm-model-catalogandwebapptest suites. Fixed by removing--skip-generateand adding--urlto pass the connection string directly to the CLI.Review & Testing Checklist for Human
DATABASE_POOL_TIMEOUT(default 60s) as Prisma'spool_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. BothidleTimeoutMillisandconnectionTimeoutMillisare set toDATABASE_CONNECTION_TIMEOUT * 1000(default 20s).pg.Poolhas 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 withduration,params, andqueryfields. 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.prisma_*Prometheus metrics and the 18 OTel gauges are gone. Verify Grafana dashboards and alerting are updated, or accept the gap. Consider addingpg.Poolstats (pool.totalCount,pool.idleCount,pool.waitingCount) in a follow-up if needed.@prisma/instrumentationv7 compatibility: Updated from^6.14.0to^7.7.0. Verify OTel tracing spans are still generated whenINTERNAL_OTEL_TRACE_INSTRUMENT_PRISMA_ENABLED=1.$transactionretry behavior: The custom$transactionwrapper 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.tsis excluded from the TypeScript build (tsconfig.json) because its types are only consumed by the Prisma CLI.DATABASE_POOL_TIMEOUTenv 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.references/prisma-7project was bumped to 7.7.0 purely to fix the hoisting conflict — it may need its ownprisma.config.tsand schema updates to actually run, but that's independent of this migration.tinyexeccall does not throw on non-zero exit codes, so the--skip-generatefailure was silent. Consider adding error handling tocreatePostgresContainerin a follow-up.Link to Devin session: https://app.devin.ai/sessions/fe7341a644774ff9acda74a2d35fb54c
Requested by: @ericallam