Older versions
This page provides upgrade guidance for older Prisma ORM versions. For upgrading to the current version, see Upgrade to v7.
Prisma ORM v6 introduced breaking changes related to Node.js versions, TypeScript versions, and schema changes for PostgreSQL.
- Minimum Node.js: 18.18.0, 20.9.0, or 22.11.0
- Minimum TypeScript: 5.1.0
- PostgreSQL implicit m-n relations: Changed from unique index to primary key
- Full-text search on PostgreSQL: Now requires
fullTextSearchPostgrespreview feature Bufferreplaced withUint8Array: ForBytesfieldsNotFoundErrorremoved: UsePrismaClientKnownRequestErrorwith codeP2025instead
bun add prisma@6 @prisma/client@6pnpm add prisma@6 @prisma/client@6yarn add prisma@6 @prisma/client@6npm install prisma@6 @prisma/client@6After upgrading, run prisma migrate dev --name upgrade-to-v6 to apply schema changes for implicit m-n relations.
Prisma ORM v5 introduced the JSON Protocol for improved performance and removed deprecated APIs.
- Minimum Node.js: 16.13.0
- Minimum TypeScript: 4.7
- Minimum PostgreSQL: 9.6
rejectOnNotFoundremoved: UsefindFirstOrThrow()orfindUniqueOrThrow()instead- Array shortcuts removed:
OR,in,notIn, andpathnow require array values - CockroachDB: Requires
cockroachdbprovider (notpostgresql)
// Before (v4 and earlier)
prisma.user.findFirst({
where: { name: "Alice" },
rejectOnNotFound: true,
});
// After (v5+)
prisma.user.findFirstOrThrow({
where: { name: "Alice" },
});// Before (v4 and earlier)
prisma.user.findMany({
where: { OR: { email: "foo@example.com" } },
});
// After (v5+)
prisma.user.findMany({
where: { OR: [{ email: "foo@example.com" }] },
});bun add prisma@5 @prisma/client@5pnpm add prisma@5 @prisma/client@5yarn add prisma@5 @prisma/client@5npm install prisma@5 @prisma/client@5Prisma ORM v4 made extended indexes generally available and introduced changes to raw queries and JSON null handling.
-
Minimum Node.js: 14.17.x
-
Extended indexes GA:
extendedIndexespreview feature removed -
Explicit
@uniquerequired: For 1relations
-
Raw query type mapping:
DateTimereturnsDate,NumericreturnsDecimal -
DbNull,JsonNull,AnyNull: Now objects instead of strings
// Before (v3 and earlier)
prisma.log.findMany({
where: { data: { meta: { equals: null } } },
});
// After (v4+)
import { Prisma } from "@prisma/client";
prisma.log.findMany({
where: { data: { meta: { equals: Prisma.AnyNull } } },
});bun add prisma@4 @prisma/client@4pnpm add prisma@4 @prisma/client@4yarn add prisma@4 @prisma/client@4npm install prisma@4 @prisma/client@4After upgrading, run npx prisma db pull to retrieve existing index configurations before creating new migrations.
Prisma ORM v3 introduced referential actions and named constraints, with significant changes to cascade delete behavior.
- Referential actions: Runtime cascade prevention removed; now handled at database level
- Named constraints: New naming convention for constraints and indexes
$queryRawchanges: Only supports template literals (use$queryRawUnsafefor strings)- JSON null types: Introduced
Prisma.DbNull,Prisma.JsonNull,Prisma.AnyNull
In v2.x, Prisma Client prevented cascading deletes at runtime. In v3+, this is handled by the database. Review your schema's onDelete settings:
model Post {
id Int @id
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
authorId Int
}After upgrading, run npx prisma db pull to sync constraint names, or run npx prisma migrate dev to update to Prisma's default naming convention.
bun add prisma@3 @prisma/client@3pnpm add prisma@3 @prisma/client@3yarn add prisma@3 @prisma/client@3npm install prisma@3 @prisma/client@3The @prisma/codemods package helps automate code changes when upgrading:
bunx @prisma/codemods <transform> <path>pnpm dlx @prisma/codemods <transform> <path>yarn dlx @prisma/codemods <transform> <path>npx @prisma/codemods <transform> <path>Available transforms:
namespace- Update@prisma/clientnamespace changesfindUnique- ConvertfindOnetofindUniqueto$- Convert deprecated methods to$prefixed versionsupdate-2.12- Apply all transforms for 2.12 upgrade
See the codemods repository for more details.