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.

referencesprisma-config.md

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

Prisma Config

Prisma v7 introduces prisma.config.ts as the central configuration file for the Prisma CLI.

Location

Place prisma.config.ts at your project root (next to package.json).

Basic Configuration

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'),
  },
})

Configuration Options

schema

Path to your Prisma schema file:

schema: 'prisma/schema.prisma'

datasource.url

Database connection URL:

datasource: {
  url: env('DATABASE_URL'),
}

datasource.directUrl

Direct connection URL (bypassing connection pooler):

datasource: {
  url: env('DATABASE_URL'),
  directUrl: env('DIRECT_DATABASE_URL'),
}

datasource.shadowDatabaseUrl

Shadow database for migrations:

datasource: {
  url: env('DATABASE_URL'),
  shadowDatabaseUrl: env('SHADOW_DATABASE_URL'),
}

migrations.path

Directory for migration files:

migrations: {
  path: 'prisma/migrations',
}

migrations.seed

Seed command for prisma db seed:

migrations: {
  path: 'prisma/migrations',
  seed: 'tsx prisma/seed.ts',
}

Full Example

import 'dotenv/config'
import { defineConfig, env } from 'prisma/config'

export default defineConfig({
  // Schema location
  schema: 'prisma/schema.prisma',
  
  // Migration configuration
  migrations: {
    path: 'prisma/migrations',
    seed: 'tsx prisma/seed.ts',
  },
  
  // Database connection
  datasource: {
    url: env('DATABASE_URL'),
    directUrl: env('DIRECT_DATABASE_URL'),
    shadowDatabaseUrl: env('SHADOW_DATABASE_URL'),
  },
})

Environment Variables

The env() helper

Use env() to reference environment variables:

import { env } from 'prisma/config'

datasource: {
  url: env('DATABASE_URL'),
}

This provides type safety but does NOT load .env files automatically.

Loading .env files

Install and import dotenv:

npm install dotenv
import 'dotenv/config'  // Must be first import
import { defineConfig, env } from 'prisma/config'

Migrating from v6

Before (v6) - schema.prisma

datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL")
  directUrl = env("DIRECT_URL")
}

After (v7) - prisma.config.ts

import 'dotenv/config'
import { defineConfig, env } from 'prisma/config'

export default defineConfig({
  schema: 'prisma/schema.prisma',
  datasource: {
    url: env('DATABASE_URL'),
    directUrl: env('DIRECT_URL'),
  },
})

And update schema.prisma:

datasource db {
  provider = "postgresql"
  // URLs now in prisma.config.ts
}

Custom Config Path

Use --config flag with CLI commands:

prisma migrate dev --config ./config/prisma.config.ts

Monorepo Configuration

import 'dotenv/config'
import { defineConfig, env } from 'prisma/config'
import path from 'path'

export default defineConfig({
  schema: path.join(__dirname, 'packages/database/prisma/schema.prisma'),
  migrations: {
    path: path.join(__dirname, 'packages/database/prisma/migrations'),
  },
  datasource: {
    url: env('DATABASE_URL'),
  },
})

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.