All skills
prisma avatar

/prisma-upgrade-v7

@5011471 official
by prismaprisma/skills68 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.

referencesaccelerate-users.md

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

Prisma Accelerate Users

Special migration instructions for users of Prisma Accelerate or Prisma Postgres with prisma:// or prisma+postgres:// URLs.

Important

Do NOT pass Accelerate URLs to driver adapters.

Driver adapters (like PrismaPg) expect direct database connection strings. They will fail with prisma:// or prisma+postgres:// URLs.

Correct v7 Setup for Accelerate

1. Keep your Accelerate URL

# .env
DATABASE_URL="prisma://accelerate.prisma-data.net/?api_key=..."
# or
DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/..."

2. Install Accelerate extension

npm install @prisma/extension-accelerate

3. Configure prisma.config.ts

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

export default defineConfig({
  schema: 'prisma/schema.prisma',
  datasource: {
    url: env('DATABASE_URL'),  // Accelerate URL works here
  },
})

4. Instantiate client with accelerateUrl

import { PrismaClient } from '../generated/client'
import { withAccelerate } from '@prisma/extension-accelerate'

// Use accelerateUrl instead of adapter
export const prisma = new PrismaClient({
  accelerateUrl: process.env.DATABASE_URL,
}).$extends(withAccelerate())

What NOT to Do

// ❌ WRONG - Don't use adapter with Accelerate URL
import { PrismaPg } from '@prisma/adapter-pg'

const adapter = new PrismaPg({
  connectionString: process.env.DATABASE_URL  // This will fail with prisma://
})

Migrations with Accelerate

For migrations, you may need a direct database connection:

Option 1: Use Accelerate URL for everything

Accelerate URLs work with Prisma CLI commands:

# Works with Accelerate URL
prisma migrate deploy
prisma db push

Option 2: Use direct URL for migrations

DATABASE_URL="prisma+postgres://..."  # For app
DIRECT_DATABASE_URL="postgresql://..."  # For migrations
// prisma.config.ts
export default defineConfig({
  datasource: {
    url: env('DIRECT_DATABASE_URL'),  // Direct URL for CLI
  },
})

Prisma Postgres (Cloud)

If using Prisma Postgres cloud database:

Same approach

import { PrismaClient } from '../generated/client'
import { withAccelerate } from '@prisma/extension-accelerate'

export const prisma = new PrismaClient({
  accelerateUrl: process.env.DATABASE_URL,  // prisma+postgres:// URL
}).$extends(withAccelerate())

Switching Away from Accelerate

If you later switch to direct TCP connection:

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

const adapter = new PrismaPg({
  connectionString: process.env.DATABASE_URL  // Direct postgres:// URL
})

export const prisma = new PrismaClient({ adapter })

Caching with Accelerate

The extension enables caching:

const users = await prisma.user.findMany({
  cacheStrategy: {
    ttl: 60,  // Cache for 60 seconds
    swr: 120, // Stale-while-revalidate for 120 seconds
  },
})

Edge Runtime

Accelerate works great in edge runtimes:

// Works in Vercel Edge, Cloudflare Workers, etc.
import { PrismaClient } from '../generated/client'
import { withAccelerate } from '@prisma/extension-accelerate'

export const prisma = new PrismaClient({
  accelerateUrl: process.env.DATABASE_URL,
}).$extends(withAccelerate())

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 38 minutes 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.