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.

referencesremoved-features.md

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

Removed Features

Several features have been removed in Prisma v7. Here's how to migrate.

Client Middleware

Removed

// ❌ No longer works in v7
prisma.$use(async (params, next) => {
  const before = Date.now()
  const result = await next(params)
  const after = Date.now()
  console.log(`Query took ${after - before}ms`)
  return result
})

Use Client Extensions Instead

// ✅ v7 approach
const prisma = new PrismaClient({ adapter }).$extends({
  query: {
    $allModels: {
      async $allOperations({ operation, model, args, query }) {
        const before = Date.now()
        const result = await query(args)
        const after = Date.now()
        console.log(`${model}.${operation} took ${after - before}ms`)
        return result
      },
    },
  },
})

Common Middleware Patterns

Soft delete
const prisma = new PrismaClient({ adapter }).$extends({
  query: {
    user: {
      async delete({ args, query }) {
        // Convert delete to soft delete
        return prisma.user.update({
          where: args.where,
          data: { deletedAt: new Date() },
        })
      },
      async findMany({ args, query }) {
        // Filter out soft-deleted records
        args.where = { ...args.where, deletedAt: null }
        return query(args)
      },
    },
  },
})
Logging
const prisma = new PrismaClient({ adapter }).$extends({
  query: {
    $allModels: {
      async $allOperations({ operation, model, args, query }) {
        console.log(`${model}.${operation}`, JSON.stringify(args))
        return query(args)
      },
    },
  },
})

Metrics

Removed

The Metrics preview feature has been removed.

// ❌ No longer works
const metrics = await prisma.$metrics.json()

Alternatives

Custom counter with extensions
let totalQueries = 0

const prisma = new PrismaClient({ adapter }).$extends({
  client: {
    async $totalQueries() {
      return totalQueries
    },
  },
  query: {
    $allModels: {
      async $allOperations({ query, args }) {
        totalQueries += 1
        return query(args)
      },
    },
  },
})

// Usage
const count = await prisma.$totalQueries()
Use driver-level metrics

Access metrics from the underlying driver adapter.

CLI Flags Removed

--skip-generate

Removed from migrate dev and db push.

# v6
prisma migrate dev --skip-generate

# v7 - generate is not run automatically
prisma migrate dev
prisma generate  # Run explicitly if needed

Local verification with Prisma 7.6.0 showed no generated client files emitted by migrate dev or db push, even though some CLI help text still says migrate dev "trigger[s] generators".

--skip-seed

Removed from migrate dev. More importantly, Prisma v7 no longer auto-runs seeds during migrate dev or migrate reset, so seed explicitly when you need it.

# v6
prisma migrate dev --skip-seed

# v7 - seed is not run automatically
prisma migrate dev
prisma db seed  # Run explicitly if needed

--schema and --url from db execute

# v6
prisma db execute --file ./script.sql --url "$DATABASE_URL"

# v7 - configure in prisma.config.ts
prisma db execute --file ./script.sql

migrate diff Options

Removed Replacement
--from-url --from-config-datasource
--to-url --to-config-datasource
--from-schema-datasource --from-config-datasource
--to-schema-datasource --to-config-datasource
--shadow-database-url Configure in prisma.config.ts

Example

# v6
prisma migrate diff --from-url "$DATABASE_URL" --to-schema schema.prisma

# v7
prisma migrate diff --from-config-datasource --to-schema schema.prisma

Automatic Behaviors Removed

Auto-generate after migrate

# v7 workflow
prisma migrate dev --name add_field
prisma generate  # Must run explicitly

Auto-seed after migrate

# v7 workflow
prisma migrate reset --force
prisma db seed  # Must run explicitly

Prisma.validator

The prisma-client generator no longer exposes Prisma.validator. Use TypeScript's satisfies operator instead.

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

const userSelect = {
  id: true,
  email: true,
} satisfies Prisma.UserSelect

rejectOnNotFound

Removed in v5.0.0 (already deprecated).

// ❌ Removed
const prisma = new PrismaClient({
  rejectOnNotFound: true,
})

// ✅ Use OrThrow methods
const user = await prisma.user.findUniqueOrThrow({
  where: { id: 1 },
})

const user = await prisma.user.findFirstOrThrow({
  where: { email: 'test@example.com' },
})

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.