Skip to content

Migrate Prisma adapter from $use() to $extends() for Prisma v7 compatibility #4

@queso

Description

@queso

Context

The current Prisma adapter (src/server/adapters/prisma.ts) uses prisma.$use() middleware to intercept create/update/delete operations. This API was deprecated in Prisma v4.16.0 and removed in Prisma v7.0.0 (November 2025).

Required Change

Migrate from $use() middleware to Prisma Client Extensions ($extends({ query: { ... } })), which is the officially supported replacement.

The $extends API provides per-model and per-operation hooks via query:

const prisma = new PrismaClient().$extends({
  query: {
    $allModels: {
      async create({ model, args, query }) { ... },
      async update({ model, args, query }) { ... },
      async delete({ model, args, query }) { ... },
    },
  },
})

Impact

  • The current adapter works with Prisma v4-v6
  • Users on Prisma v7+ cannot use createPrismaAdapter at all
  • The adapter interface (SSEAdapter) stays the same — only the internal registration mechanism changes

Acceptance Criteria

  • Adapter uses $extends() instead of $use()
  • Works with Prisma v7+
  • Existing tests pass (update mocks as needed)
  • README updated to remove version constraint note

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions