prisma-upgrade-v7

von prisma

Vollständiger Migrationsleitfaden für das Upgrade von Prisma ORM von v6 auf v7 mit ESM, Treiberadaptern und neuer Konfiguration. Deckt sieben kritische Regelkategorien ab: Schema-Migration, Treiberadapter, ESM-Unterstützung, Konfiguration, entfernte Funktionen und Accelerate-spezifische Änderungen. Erfordert Node.js 20.19.0+ und TypeScript 5.4.0+; MongoDB wird in v7 noch nicht unterstützt. Zu den Breaking Changes gehören reine ESM-Module, erforderliche Treiberadapter, explizite Ausgabepfade und die Konfiguration von prisma.config.ts. Bietet eine Schritt-für-Schritt-Anleitung...

npx skills add https://github.com/prisma/skills --skill prisma-upgrade-v7

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-client generator
  • Setting up driver adapters
  • Configuring prisma.config.ts
  • Fixing import errors after upgrade

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Schema MigrationCRITICALschema-changes
2Database ConnectivityCRITICALdriver-adapters
3Module SystemCRITICALesm-support
4Config and EnvHIGHprisma-config, env-variables
5Removed FeaturesHIGHremoved-features
6AccelerateHIGHaccelerate-users

Quick Reference

  • schema-changes - generator migration, required output paths, generated entrypoints, and Prisma.validator replacement
  • driver-adapters - required adapter installation for SQL providers, pool differences, and Prisma Postgres adapter choices
  • esm-support - ESM-first setup plus CommonJS fallback with moduleFormat = "cjs"
  • prisma-config - creating and using prisma.config.ts
  • env-variables - explicit environment loading
  • removed-features - removed middleware, metrics, and legacy CLI behavior
  • accelerate-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 Next).

Important Notes

  • MongoDB projects should stay on Prisma 6.x or migrate to Prisma Next - 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

  1. Update packages to v7
  2. Choose your module format (esm by default, cjs if needed)
  3. Update TypeScript configuration
  4. Update the schema generator block
  5. Create prisma.config.ts
  6. Install and configure a driver adapter for SQL providers
  7. Update Prisma Client imports
  8. Update client instantiation
  9. Replace deprecated helper patterns like Prisma.validator
  10. Run prisma generate and 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

Changev6v7
Module formatImplicit / mixedESM-first, moduleFormat = "cjs" supported
Generator providerprisma-client-jsprisma-client is the default, while prisma-client-js still exists for legacy setups
Output pathAuto (node_modules)Required explicit
Driver adaptersOptionalRequired for SQL providers
Config file.env + schemaprisma.config.ts
Env loadingAutomaticManual (dotenv)
Generated entrypointsSingle package exportclient, browser, models, enums entrypoints
Type-safe query fragmentsPrisma.validator()TypeScript satisfies
Middleware$use()Client Extensions
MetricsPreview featureRemoved

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 output path matches your import path
  • Ensure prisma generate ran 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.

Mehr Skills von prisma

prisma-cli-migrate-reset
prisma
prisma migrate reset
official
prisma-cli-validate
prisma
prisma validieren. Referenz bei Verwendung dieser Prisma-Funktion.
official
prisma-next-extension-upgrade
prisma
Upgrade Prisma Next in your extension. Bumps every `@prisma-next/*` dependency to the requested target (or npm `latest`), runs the per-transition upgrade…
official
adr-review
prisma
Überprüfen Sie einen oder mehrere ADRs mit frischem Blick (als Teammitglied ohne Vorkenntnisse), identifizieren Sie narrative und strukturelle Probleme und schreiben Sie sie dann um. Verwenden Sie, wenn die…
official
prisma-next-upgrade
prisma
Upgrade Prisma Next in your app. Bumps every `@prisma-next/*` dependency from the version pinned in the lockfile to the requested target (or npm `latest`),…
official
prisma-cli
prisma
Vollständige Referenz für Prisma CLI-Befehle, Optionen und Workflows für Setup, Migrationen und Datenbankoperationen. Deckt über 20 Befehle ab, geordnet nach Priorität: Setup (init), Generierung (generate), Entwicklung (dev), Datenbankoperationen (db pull/push/seed/execute) und Migrationen (migrate dev/deploy/reset/status/diff/resolve). Enthält Änderungen in Prisma 7.x: neue prisma.config.ts-Konfigurationsdatei, entfernte Flags (--skip-generate, --skip-seed, --schema, --url) und explizite...
official
prisma-client-api
prisma
Vollständige Prisma Client API-Referenz für Modellabfragen, CRUD-Operationen, Filterung, Beziehungen und Transaktionen. Deckt 17 Modellabfragemethoden ab, darunter findUnique, findMany, create, update, delete, upsert und Bulk-Operationen mit Rückgabevarianten. Bietet Abfrageoptionen zur Ergebnisgestaltung: select, include, omit, orderBy, take, skip, cursor und distinct. Enthält skalare und logische Filteroperatoren (equals, in, contains, startsWith, lt, gt) sowie Beziehungsfilter (some,...
official
prisma-compute
prisma
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`, `auth workspace`, Compute apps/deployments/build logs/domains, `@prisma/cli agent install`, localhost vs `0.0.0.0`, deploy port binding, or framework deploy readiness for Hono, Elysia, Next.js, TanStack Start, Astro, Nuxt, Svelte,...
developmentdevopsofficial