Older versions
Upgrade guides for Prisma ORM versions 3, 4, 5, and 6
This page provides upgrade guidance for older Prisma ORM versions. For upgrading to the current version, see Upgrade to v7.
Upgrading to v6
Prisma ORM v6 introduced breaking changes related to Node.js versions, TypeScript versions, and schema changes for PostgreSQL.
Key breaking changes
- 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
Upgrade command
npm install prisma@6 @prisma/client@6After upgrading, run prisma migrate dev --name upgrade-to-v6 to apply schema changes for implicit m-n relations.
Upgrading to v5
Prisma ORM v5 introduced the JSON Protocol for improved performance and removed deprecated APIs.
Key breaking changes
- 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)
Example: Replacing rejectOnNotFound
// Before (v4 and earlier)
prisma.user.findFirst({
where: { name: "Alice" },
rejectOnNotFound: true,
});
// After (v5+)
prisma.user.findFirstOrThrow({
where: { name: "Alice" },
});Example: Array values required
// Before (v4 and earlier)
prisma.user.findMany({
where: { OR: { email: "foo@example.com" } },
});
// After (v5+)
prisma.user.findMany({
where: { OR: [{ email: "foo@example.com" }] },
});Upgrade command
npm install prisma@5 @prisma/client@5Upgrading to v4
Prisma ORM v4 made extended indexes generally available and introduced changes to raw queries and JSON null handling.
Key breaking changes
- Minimum Node.js: 14.17.x
- Extended indexes GA:
extendedIndexespreview feature removed - Explicit
@uniquerequired: For 1 relations - Raw query type mapping:
DateTimereturnsDate,NumericreturnsDecimal DbNull,JsonNull,AnyNull: Now objects instead of strings
Example: JSON null values
// 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 } } },
});Upgrade command
npm install prisma@4 @prisma/client@4After upgrading, run npx prisma db pull to retrieve existing index configurations before creating new migrations.
Upgrading to v3
Prisma ORM v3 introduced referential actions and named constraints, with significant changes to cascade delete behavior.
Key breaking changes
- 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
Referential actions
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
}Named constraints
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.
Upgrade command
npm install prisma@3 @prisma/client@3Codemods
The @prisma/codemods package helps automate code changes when upgrading:
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.