prisma-upgrade-v7
Complete migration guide from Prisma ORM v6 to v7 covering all breaking changes. Use when upgrading Prisma versions, encountering v7 errors, or migrating existing projects. Triggers on "upgrade to prisma 7", "prisma 7 migration", "prisma-client generator", "driver adapter required".
- 0
- Installs
- —
- Rating
- —
- Success rate
- 8
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 0f1f9740fa8946dc… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
Upgrade to Prisma ORM 7
Complete guide for migrating from Prisma ORM v6 to v7. This upgrade introduces significant breaking changes around the new prisma-client generator, driver adapters, prisma.config.ts, explicit environment loading, and generated client entrypoints.
When to Apply
Reference this skill when:
- Upgrading from Prisma v6 to v7
- Updating to the
prisma-clientgenerator - Setting up driver adapters
- Configuring
prisma.config.ts - Fixing import errors after upgrade
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Schema Migration | CRITICAL | schema-changes |
| 2 | Database Connectivity | CRITICAL | driver-adapters |
| 3 | Module System | CRITICAL | esm-support |
| 4 | Config and Env | HIGH | prisma-config, env-variables |
| 5 | Removed Features | HIGH | removed-features |
| 6 | Accelerate | HIGH | accelerate-users |
Quick Reference
schema-changes- generator migration, required output paths, generated entrypoints, andPrisma.validatorreplacementdriver-adapters- required adapter installation for SQL providers, pool differences, and Prisma Postgres adapter choicesesm-support- ESM-first setup plus CommonJS fallback withmoduleFormat = "cjs"prisma-config- creating and usingprisma.config.tsenv-variables- explicit environment loadingremoved-features- removed middleware, metrics, and legacy CLI behavioraccelerate-users- migration notes for Accelerate users
Using MongoDB? This guide does not apply
Prisma 7 has no MongoDB connector. Do not apply any step in this guide to a project with
provider = "mongodb" — see the prisma-mongodb-upgrade skill for the actual decision
(stay on v6 deliberately vs migrate to Prisma 8).
Important Notes
- MongoDB projects should stay on Prisma 6.x or migrate to Prisma 8 - do not migrate MongoDB apps to Prisma 7's SQL client path (see
prisma-mongodb-upgrade) - Node.js 20.19.0+ required
- TypeScript 5.4.0+ required
- Latest stable Prisma ORM version:
7.6.0
Upgrade Steps Overview
- Update packages to v7
- Choose your module format (
esmby default,cjsif needed) - Update TypeScript configuration
- Update the schema generator block
- Create
prisma.config.ts - Install and configure a driver adapter for SQL providers
- Update Prisma Client imports
- Update client instantiation
- Replace deprecated helper patterns like
Prisma.validator - Run
prisma generateand test
Quick Upgrade Commands
# Update packages
npm install @prisma/client@7
npm install -D prisma@7
# Install a driver adapter (PostgreSQL or Prisma Postgres via direct TCP)
npm install @prisma/adapter-pg pg
# Install dotenv for env loading
npm install dotenv
# Regenerate client
npx prisma generate
Breaking Changes Summary
| Change | v6 | v7 |
|---|---|---|
| Module format | Implicit / mixed | ESM-first, moduleFormat = "cjs" supported |
| Generator provider | prisma-client-js | prisma-client is the default, while prisma-client-js still exists for legacy setups |
| Output path | Auto (node_modules) | Required explicit |
| Driver adapters | Optional | Required for SQL providers |
| Config file | .env + schema | prisma.config.ts |
| Env loading | Automatic | Manual (dotenv) |
| Generated entrypoints | Single package export | client, browser, models, enums entrypoints |
| Type-safe query fragments | Prisma.validator() | TypeScript satisfies |
| Middleware | $use() | Client Extensions |
| Metrics | Preview feature | Removed |
Rule Files
Detailed migration guides for each breaking change:
references/esm-support.md - ESM and CommonJS configuration
references/schema-changes.md - Generator, output, imports, and generated entrypoints
references/driver-adapters.md - Required driver adapter setup
references/prisma-config.md - New configuration file
references/env-variables.md - Environment variable loading
references/removed-features.md - Middleware, metrics, and CLI flags
references/accelerate-users.md - Special handling for Accelerate
Step-by-Step Migration
1. Update package.json for ESM-first projects
{
"type": "module"
}
If you need to stay on CommonJS, keep your app as CJS and set moduleFormat = "cjs" in the generator block instead of forcing ESM.
2. Update tsconfig.json
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "bundler",
"target": "ES2023",
"strict": true,
"esModuleInterop": true
}
}
3. Update schema.prisma
// Before (v6)
generator client {
provider = "prisma-client-js"
}
// After (v7)
generator client {
provider = "prisma-client"
output = "../generated/prisma"
// Optional if you need CommonJS:
// moduleFormat = "cjs"
}
4. Create prisma.config.ts
import 'dotenv/config'
import { defineConfig, env } from 'prisma/config'
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
},
datasource: {
url: env('DATABASE_URL'),
},
})
5. Install a driver adapter (SQL providers only)
# PostgreSQL
npm install @prisma/adapter-pg pg
# MySQL
npm install @prisma/adapter-mariadb mariadb
# SQLite
npm install @prisma/adapter-better-sqlite3 better-sqlite3
# Prisma Postgres in standard Node.js apps (recommended)
npm install @prisma/adapter-pg pg
# Prisma Postgres serverless driver (edge/serverless)
npm install @prisma/adapter-ppg @prisma/ppg
# Neon
npm install @prisma/adapter-neon
MongoDB does not have a SQL @prisma/adapter-* package in the published Prisma 7.6.0 packages. If you're upgrading a MongoDB project, stop and keep that project on the latest Prisma 6.x release instead of following the standard Prisma 7 migration path.
6. Update client instantiation
// Before (v6)
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
// After (v7)
import { PrismaClient } from '../generated/prisma/client'
import { PrismaPg } from '@prisma/adapter-pg'
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL
})
const prisma = new PrismaClient({ adapter })
7. Replace Prisma.validator with satisfies
import { Prisma } from '../generated/prisma/client'
const userSelect = {
id: true,
email: true,
name: true,
} satisfies Prisma.UserSelect
8. Run migrations and generate
npx prisma generate
npx prisma migrate dev # if needed
Troubleshooting
"Cannot find module" errors
- Check that the generator
outputpath matches your import path - Ensure
prisma generateran successfully
SSL certificate errors
- Add
ssl: { rejectUnauthorized: false }to the adapter config if you need to preserve old behavior - Or configure your certificates properly with
NODE_EXTRA_CA_CERTS/ OpenSSL CA settings
Connection timeout issues
- Driver adapters use the underlying driver's defaults, which differ from v6
- Configure pool settings explicitly on the adapter if needed
Resources
How to Use
Follow references/schema-changes.md and references/driver-adapters.md first, then apply the remaining reference files based on your project setup.
Files
8- SKILL.md
03d79d99b67.9 KB - references/accelerate-users.md
fa70c8d9b03.4 KB - references/driver-adapters.md
5c4b4877496.0 KB - references/env-variables.md
5b11d1d6253.3 KB - references/esm-support.md
558b2cff563.1 KB - references/prisma-config.md
84e372368b3.3 KB - references/removed-features.md
eb88f9dd5a4.6 KB - references/schema-changes.md
cfd913c0d53.6 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from prisma/skills8
Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
Prisma Compute deployment and hosting guide. Use whenever the user mentions Prisma Compute, `prisma.compute.ts`, `defineComputeConfig`, deploying or hosting a Prisma app, `@prisma/cli app deploy`, `compute:deploy`, `create-prisma --deploy`, `PRISMA_SERVICE_TOKEN`, Compute auth/workspaces, apps/deplo
Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.
Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, ori
Decision and migration guide for Prisma ORM MongoDB projects on v6, which have no upgrade path to v7. Use when a MongoDB project asks about upgrading Prisma, when "upgrade to prisma 7" comes up in a project with provider = "mongodb", or when evaluating a move to Prisma 8. Triggers on "upgrade prisma
Set up Prisma ORM in an application, connect its database, or troubleshoot the connection of an existing Prisma 6, 7, or 8 app. Defaults new applications to Prisma ORM 8 and loads the package-owned prisma-8 skill; keeps existing Prisma 6/7 apps on their version with provider references for PostgreSQ
Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.
Related database skillsscan passed
USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs. Use when a task needs official United States patent or trademark records from USPTO systems.
Use when the user wants to provision infrastructure or third-party services using Stripe Projects. Triggers: "I need a database", "set up auth", "add caching", "give me a Postgres", "provision Redis", "I need hosting", "add a vector DB", "get me an API key for X", "get credentials for X", "sign up f
Build and troubleshoot Cloudflare Basin analytics workflows with Basin Pipelines, Basin Catalog, and Basin SQL. Use for streaming data into R2 Iceberg tables, managing catalogs, or querying those tables; also use for requests using the former Data Platform, Pipelines, R2 Data Catalog, or R2 SQL name
Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to
Builds and deploys Firebase SQL Connect (aka Firebase Data Connect) backends with PostgreSQL securely. Use when designing schemas with tables and relations, writing authorized queries and mutations, configuring real-time data updates, or generating type-safe SDKs. Use when you need a relational data
Creates a complete Amazon Aurora database cluster with instances, handling cluster creation, instance provisioning, and Secrets Manager password management in the proper sequence. Use when setting up new Aurora MySQL or PostgreSQL clusters with production-ready configuration.