All skills
prisma avatar

/prisma-upgrade-v7

@5011471 official
by prismaprisma/skills66 stars
7

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".

Use this Skill: https://skilld.dev/gh/prisma/skills/prisma-upgrade-v7

This session only. Nothing lands on disk.

referencesesm-support.md

≈803 tokens on demand. Your agent reads this file only when SKILL.md points to it.

ESM and CommonJS Support

Prisma ORM v7 is ESM-first, but the prisma-client generator can target either ESM or CommonJS. Use ESM by default, and opt into CommonJS with moduleFormat = "cjs" if your project still needs it.

ESM Projects

Add "type": "module" to package.json and use an ESM-compatible tsconfig.json:

{
  "type": "module",
  "scripts": {
    "build": "tsc",
    "start": "node dist/index.js"
  }
}
{
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "bundler",
    "target": "ES2023",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "outDir": "dist"
  },
  "include": ["src/**/*", "prisma/**/*"]
}

CommonJS Projects

If the rest of your app is still CommonJS, keep that setup and make the generated Prisma Client CommonJS too:

{
  "compilerOptions": {
    "module": "CommonJS",
    "moduleResolution": "node",
    "target": "ES2022",
    "esModuleInterop": true
  }
}
generator client {
  provider     = "prisma-client"
  output       = "../generated/prisma"
  moduleFormat = "cjs"
}

Generator Fields That Matter

  • moduleFormat: esm or cjs
  • runtime: nodejs, bun, deno, workerd, vercel-edge, react-native
  • generatedFileExtension: ts, mts, or cts
  • importFileExtension: ts, mts, cts, js, mjs, cjs, or empty

Example:

generator client {
  provider               = "prisma-client"
  output                 = "../generated/prisma"
  runtime                = "nodejs"
  moduleFormat           = "esm"
  generatedFileExtension = "ts"
  importFileExtension    = "ts"
}

Import Paths

Server Code

import { PrismaClient } from '../generated/prisma/client'

Browser-Safe Types

import { Prisma } from '../generated/prisma/browser'
import { Role } from '../generated/prisma/enums'
import type { UserModel } from '../generated/prisma/models/User'

File Extensions

With moduleResolution: "Node16" or "NodeNext", use .js/.mjs/.cjs extensions that match your emitted files.

With moduleResolution: "bundler", bare relative imports are usually fine.

Minimum Versions

Requirement Minimum Version
Node.js 20.19.0
TypeScript 5.4.0

Framework Considerations

Next.js

Next.js works well with the default ESM output. If you need generated types in client components, import them from browser, models, or enums, not from client.

Bun

Bun loads .env files automatically, so ESM plus env() is the smoothest default. You can still choose moduleFormat = "cjs" if the rest of your project requires it.

Troubleshooting

"ERR_REQUIRE_ESM"

Your generated client is ESM, but your app is requiring it as CommonJS. Either switch the project to ESM or set moduleFormat = "cjs" and regenerate.

"Cannot use import statement outside a module"

Your app is still being executed as CommonJS. Add "type": "module" or use moduleFormat = "cjs" instead.

TypeScript compilation errors

Ensure module, moduleResolution, and your generator's moduleFormat agree with one another.

Source: SKILL.md on GitHub

1 warning1d5 checks · Risk SAFE
  • Gen Agent Trust Hub1d

    This skill is a legitimate technical migration guide for upgrading Prisma ORM from version 6 to version 7. It provides accurate instructions for updating packages, configuring driver adapters, and adapting to breaking changes in the library. All referenced packages and URLs belong to the official Prisma organization or well-known database driver projects.

  • Socket1d

    No alerts

  • Snyk1d

    Risk: LOW · No issues

  • Runlayer7mo

    8/8 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 5011471. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 days ago
metadata
{
  "author": "prisma",
  "version": "7.6.0"
}
  • TypeScript
  • prisma
  • orm
  • migrations
  • driver-adapters
  • esm
  • schema
  • postgres
  • mysql
  • sqlite

README badge

README badge for prisma/skills/prisma-upgrade-v7

Guides migration from Prisma ORM v6 to v7, covering breaking changes in the generator, driver adapters, module format (ESM-first), prisma.config.ts setup, and client instantiation. Handles schema updates, environment loading, removed features like middleware, and provides adapter installation commands for PostgreSQL, MySQL, SQLite, and Prisma Postgres. Not applicable to MongoDB projects, which should remain on v6.

Generated from the current SKILL.md.

Does this skill cover MongoDB projects?
No. MongoDB projects should stay on Prisma 6.x. This skill only covers SQL database migrations to Prisma v7.
What are the minimum Node.js and TypeScript versions required?
Node.js 20.19.0+ and TypeScript 5.4.0+ are required for Prisma v7.
Do I have to use ESM, or can I stay on CommonJS?
You can stay on CommonJS by setting `moduleFormat = "cjs"` in the generator block. ESM is the default but not required.
What driver adapters are supported?
PostgreSQL, MySQL, SQLite, Neon, and Prisma Postgres (standard and serverless). MongoDB is not supported in v7's SQL client path.
How do I replace Prisma.validator, which was removed?
Use TypeScript's `satisfies` keyword instead. For example: `const userSelect = {...} satisfies Prisma.UserSelect`.

Generated from the current SKILL.md. These answers refresh after source changes.