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.

referencesenv-variables.md

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

Environment Variables

Prisma v7 no longer automatically loads environment variables. You must load them explicitly.

The Change

v6 Behavior

Prisma CLI automatically loaded .env files.

v7 Behavior

You must manually load environment variables using dotenv or similar.

Setup

1. Install dotenv

npm install dotenv

2. Import in prisma.config.ts

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

export default defineConfig({
  datasource: {
    url: env('DATABASE_URL'),
  },
})

Bun Users

Bun automatically loads .env files. No additional setup needed:

// prisma.config.ts (Bun)
import { defineConfig, env } from 'prisma/config'

export default defineConfig({
  datasource: {
    url: env('DATABASE_URL'),
  },
})

Multiple .env Files

Using dotenv-cli

npm install -D dotenv-cli
{
  "scripts": {
    "db:migrate": "dotenv -e .env.local -- prisma migrate dev",
    "db:push": "dotenv -e .env.development -- prisma db push"
  }
}

Using dotenv with path

// prisma.config.ts
import { config } from 'dotenv'
import path from 'path'

// Load specific .env file
config({ path: path.join(__dirname, '.env.local') })

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

export default defineConfig({
  datasource: {
    url: env('DATABASE_URL'),
  },
})

Application Code

For your application, load env vars at startup:

Entry point

// index.ts
import 'dotenv/config'

import { PrismaClient } from '../generated/client'
import { PrismaPg } from '@prisma/adapter-pg'

const adapter = new PrismaPg({
  connectionString: process.env.DATABASE_URL!
})

const prisma = new PrismaClient({ adapter })

Or use dotenv explicitly

import { config } from 'dotenv'
config()

// Now process.env.DATABASE_URL is available

Removed Environment Variables

These Prisma-specific env vars are removed in v7:

Removed Variable Alternative
PRISMA_CLI_QUERY_ENGINE_TYPE Not needed (no engines)
PRISMA_CLIENT_ENGINE_TYPE Not needed (no engines)
PRISMA_QUERY_ENGINE_BINARY Not needed
PRISMA_QUERY_ENGINE_LIBRARY Not needed
PRISMA_GENERATE_SKIP_AUTOINSTALL Not needed
PRISMA_SKIP_POSTINSTALL_GENERATE Not needed
PRISMA_GENERATE_IN_POSTINSTALL Not needed
PRISMA_GENERATE_DATAPROXY Migrate to prisma-client with driver adapters
PRISMA_GENERATE_NO_ENGINE Migrate to prisma-client with driver adapters
PRISMA_CLIENT_NO_RETRY Configure on adapter
PRISMA_MIGRATE_SKIP_GENERATE Not needed (auto-generate removed)
PRISMA_MIGRATE_SKIP_SEED Not needed (auto-seed removed)

TypeScript env() Helper

The env() function from prisma/config provides type safety:

import { env } from 'prisma/config'

// Type-safe environment variable access
const url = env('DATABASE_URL')  // string

Note: This only works within prisma.config.ts, not in your application code.

CI/CD Considerations

Ensure environment variables are set in your CI environment:

# GitHub Actions
env:
  DATABASE_URL: ${{ secrets.DATABASE_URL }}

steps:
  - run: npx prisma migrate deploy

No need for dotenv in CI if variables are set directly.

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 2 days ago.

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.