Prisma Client is an auto-generated, type-safe and modern JavaScript/TypeScript ORM for Node.js that's tailored to your data. Supports PostgreSQL, CockroachDB, MySQL, MariaDB, SQL Server, SQLite & MongoDB databases.
Last release 6 days ago
27 Aug 2026
Ships fairly regularly
a new release about every 1 weeks
Nearly every release is documented
notes for 60 of the last 60 stable releases
3 versions withdrawn
withdrawn after publishing
7 years old
10653 releases · first in 2020
One column per quarter.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
We're excited to share the 4.0.0 stable release today. 🎉
Prisma 4.0.0 features a variety of improvements across Prisma Migrate, Prisma schema, and Prisma Client. These changes will impact most Prisma users, particularly those who used some of our most popular Preview features around advanced index management, raw SQL queries, and filtering rows by properties of JSON.
As this is a major release, we included many breaking bug fixes and other enhancements, but we believe upgrading is worthwhile. You can learn about upgrading in our Prisma 4 Upgrade guide and the Prisma 4 Upgrade video.
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Here's a TL;DR:
extendedIndexesfilterJsonimprovedQueryRawreferences on implicit m:n relationsreferences argument in 1:1 and 1:m relations for MySQLtype aliassqlite protocol for SQLite URLsfindUniqueOrThrowfindFirstOrThrowrejectOnNotFoundDbNull, JsonNull, and AnyNull are now objects@prisma/sdk npm package to @prisma/internalsschema property from the generated Prisma ClientextendedIndexes is now Generally AvailableStarting with this release, we're excited to announce that extendedIndexes is now Generally Available! 🚀
generator client {
provider = "prisma-client-js"
- previewFeatures = ["extendedIndexes"]
}
We introduced extendedIndexes in 3.5.0 and have constantly been shipping improvements in the subsequent releases to the configuration of indexes.
You can now configure indexes in your Prisma schema with the @@index attribute to define the kind of index that should be created in your database. You can configure the following indexes in your Prisma Schema:
<details> <summary> Sort, sort order, and length</summary>
The length argument is available on MySQL on the @id, @@id, @unique, @@unique, and @@index fields. It allows Prisma to support indexes and constraints on String with a TEXT native type and Bytes types.
The sort argument is available for all databases on the @unique, @@unique, and @@index fields. SQL Server also allows it on @id and @@id.
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model Post {
title String @db.VarChar(300)
abstract String @db.VarChar(3000)
slug String @unique(sort: Desc, length: 42) @db.VarChar(3000)
author String
created_at DateTime
@@id([title(length: 100), abstract(length: 10)])
@@index([author, created_at(sort: Desc)])
}
</details>
<details> <summary> Hash indexes for PostgreSQL </summary>
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model A {
id Int @id
value Int
@@index([value], type: Hash)
}
</details>
<details> <summary> <code>GIN</code>, <code>GiST</code>, <code>SP-GiST</code> and <code>BRIN</code> indexes for PostgreSQL </summary>
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Post {
id Int @id
title String
content String?
tags Json?
@@index([tags], type: Gin)
}
</details>
<details> <summary> SQL Server index clustering </summary>
datasource db {
provider = "sqlserver"
url = env("DATABASE_URL")
}
model Post {
id Int @default(autoincrement()) @id(clustered: false)
title String
content String?
}
</details>
Refer to our docs to learn how you can configure indexes in your Prisma schema and the supported indexes for the different databases.
⚠️ Breaking change: If you previously configured the index properties at the database level, refer to the upgrade guide for a detailed explanation and steps to follow.
filterJson is now Generally AvailableThis release moves the filterJson Preview feature into General Availability! 🪄
generator client {
provider = "prisma-client-js"
- previewFeatures = ["filterJson"]
}
JSON filtering allows you to filter rows by the data inside a Json type. For example:
const getUsers = await prisma.user.findMany({
where: {
petMeta: {
path: ['cats', 'fostering'],
array_contains: ['Fido'],
},
},
})
The filterJson Preview feature has been around since May 2021, and we're excited to mark it ready for production use! Learn more in our documentation.
improvedQueryRaw is now Generally AvailablePrisma 4 now marks the improvedQueryRaw Preview feature as Generally Available! 🤩
generator client {
provider = "prisma-client-js"
- previewFeatures = ["improvedQueryRaw"]
}
This change introduces two major improvements (both breaking, refer to the upgrade guide for a smooth upgrade) when working with raw queries with Prisma:
<details> <summary>
Raw queries now deserialize scalar values to their corresponding JavaScript types.
Note: Types are inferred from the values and not from the Prisma Schema types.
Here's an example query and response:
const res = await prisma.$queryRaw`SELECT bigint, bytes, decimal, date FROM "Table";`
console.log(res)
// [{ bigint: BigInt("123"), bytes: Buffer.from([1, 2]), decimal: new Prisma.Decimal("12.34"), date: Date("<some_date>") }]
Below is a table that recaps the serialization type-mapping for raw results:
| Database Type | JavaScript Type |
|---|---|
| Text | String |
| Int32 | Number |
| Int64 | BigInt |
| Float | Number |
| Double | Number |
| Numeric | Decimal |
| Bytes | Buffer |
| Json | Object |
| DateTime | Date |
| Date | Date |
| Time | Date |
| Uuid | String |
| Xml | String |
</details>
<details> <summary> 2. PostgreSQL type-casts </summary>
Previously, PostgreSQL type-casts were broken. Here's an example query that used to fail:
await prisma.$queryRaw`SELECT ${1.5}::int as int`;
// Before: db error: ERROR: incorrect binary data format in bind parameter 1
// After: [{ int: 2 }]
You can now perform some type-casts in your queries as follows:
await prisma.$queryRaw`SELECT ${2020}::float4, (NOW() - ${"1 day"}::interval), ${"2022-01-01 00:00:00"}::timestamptz;`
A consequence of this fix is that some subtle implicit casts are now handled more strictly and would fail. Here's an example that used to work but won't work anymore:
await prisma.$queryRaw`SELECT LENGTH(${42});`
// ERROR: function length(integer) does not exist
// HINT: No function matches the given name and argument types. You might need to add explicit type casts.
The LENGTH PostgreSQL function only accept text as input. Prisma used to silently coerce 42 to text but won’t anymore. As suggested by the hint, cast 42 to text as follows:
await prisma.$queryRaw`SELECT LENGTH(${42}::text);`
</details>
Refer to our docs to learn more on raw query type mappings in Prisma.
⚠️ Breaking change: To learn how you can smoothly upgrade to version 4.0.0, refer to our upgrade guide: Raw query type mapping: scalar values are now deserialized as their correct JavaScript types and Raw query mapping: PostgreSQL type-casts.
Prisma 4 now introduces support for defining default values for scalar lists (arrays) in the Prisma schema.
You can define default scalar lists as follows:
model User {
id Int @id @default(autoincrement())
posts Post[]
favoriteColors String[] @default(["red", "blue", "green"])
}
To learn more about default values for scalar lists, refer to our docs.
⚠️ Breaking change: Refer to the upgrade guide for a detailed explanation and steps to follow.
From version 4.0.0, you can now set default values on embedded documents using the @default attribute. Prisma will provide the specified default value on reads if a field is not defined in the database.
You can define default values for embedded documents in your Prisma schema as follows:
model Product {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String @unique
photos Photo[]
}
type Photo {
height Int @default(200)
width Int @default(100)
url String
}
Refer to our docs to learn more on default values for required fields on composite types.
⚠️ Breaking change: Refer to our upgrade guide for detailed explanation and steps when working with default fields on composite types in MongoDB from version 4.0.0.
From version 4.0.0, 1:1 relations are now required to be marked with the @unique attribute on the side of the relationship that contains the foreign key.
Previously, the relation fields were implicitly treated as unique under the hood. The field was also added explicitly when npx prisma format was run.
model User {
id Int @id @default(autoincrement())
profile Profile? @relation(fields: [profileId], references: [id])
profileId Int? @unique // <-- include this explicitly
}
model Profile {
id Int @id @default(autoincrement())
user User?
}
⚠️ Breaking change: Refer to our upgrade path for a detailed explanation and steps to follow.
references on implicit m:n relationsThis release removes the usage of the references argument, which was previously optional when using m:n relations.
model Post {
id Int @id @default(autoincrement())
- categories Category[] @relation("my-relation", references: [id])
+ categories Category[] @relation("my-relation")
}
model Category {
id Int @id @default(autoincrement())
- posts Post[] @relation("my-relation", references: [id])
+ posts Post[] @relation("my-relation")
}
This is because the only valid value for references was id, so removing this argument clarifies what can and cannot be changed.
Refer to our docs to learn more about implicit m:n relations.
⚠️ Breaking change: Refer to the upgrade guide for a detailed explanation and steps to follow.
references argument in 1:1 and 1:m relations for MySQLFrom version 4.0.0, Prisma will now enforce that the field on the references side of a @relation is unique when working with MySQL.
To fix this, add the @unique or @id attributes to foreign key fields in your Prisma schema.
⚠️ Breaking change: To learn how to upgrade to version 4.0.0, refer to our upgrade guide.
type aliasWith 4.0.0, we're deprecating the type keyword for string aliasing. The type keyword will now be exclusively used for defining embedded documents in MongoDB.
We encourage you to remove any usage of the type keyword from your Prisma schema for type aliasing.
sqlite protocol for SQLite URLsStarting from 4.0.0, we are dropping support of the sqlite:// URL prefix for SQLite. We encourage you to use the file:// prefix when working with SQLite.
String literals in the Prisma schema now need to follow the same rules as strings in JSON. That changes mostly the escaping of some special characters.
You can find more details on the specification here:
To fix this, resolve the validation errors in your Prisma schema or run npx prisma db pull to get the current values from the database.
⚠️ Breaking change: To learn how to update your existing schema, refer to the upgrade guide.
findUniqueOrThrow and findFirstOrThrowIn this release, we're introducing two new APIs to Prisma Client:
findUniqueOrThrow – retrieves a single record as findUnique but throws a RecordNotFound exception when no record is not foundfindFirstOrThrow – retrieves the first record in a list as findFirst but throws a RecordNotFound exception when no record is foundHere's an example of usage of the APIs:
const user = await prisma.user.findUniqueOrThrow({
where: {
email: "[email protected]",
},
})
user.email // You don't need to check if the user is null
The APIs will be convenient for scripts API routes where you're already handling exceptions and want to fail fast.
Note: Please use the APIs with care. If you use these APIs, add the proper guardrails to your application.
Refer to the API reference in our docs to learn how findUniqueOrThrow and findFirstOrThrow differ from findUnique and findFirst respectively.
rejectOnNotFoundWe're deprecating the rejectOnNotFound parameter in favor of the new findUniqueOrThrow and findFirstOrThrow Prisma Client APIs.
We expect the new APIs to be easier to understand and more type-safe.
Refer to the findUniqueOrThrow and findFirstOrThrow docs to learn how you can upgrade.
SQLite is a loosely-typed database. While Prisma will prevent you from inserting values larger than integers, nothing prevents SQLite from accepting big numbers. These manually inserted big numbers cause rounding errors when queried.
Prisma will now check numbers in the query's response to verify they fit within the boundaries of an integer. If a number does not fit, Prisma will throw a P2023 error:
Inconsistent column data: Conversion failed:
Value 9223372036854775807 does not fit in an INT column,
try migrating the 'int' column type to BIGINT
To learn more on rounding errors with big numbers on SQLite, refer to our docs.
DbNull, JsonNull, and AnyNull are now objectsPreviously, Prisma.DbNull, Prisma.JsonNull, and Prisma.AnyNull used to be implemented using string constants. This meant their types overlapped with regular string data that could be stored in JSON fields.
We've now made them special objects instead that don't overlap with string types.
Before 4.0.0 DbNull was checked as a string so you could accidentally check for a null as follows:
import { PrismaClient, Prisma } from '@prisma/client'
const prisma = new PrismaClient()
const dbNull = "DbNull" // this string could come from anywhere!
await prisma.log.findMany({
data: {
meta: dbNull,
},
})
<details> <summary>Expand to view the underlying Prisma schema</summary>
model Log {
id Int @id
meta Json
}
</details>
Prisma 4 resolves this using constants guaranteed to be unique to prevent this kind of inconsistent queries.
You can now read, write, and filter JSON fields as follows:
import { PrismaClient, Prisma } from '@prisma/client'
const prisma = new PrismaClient()
await prisma.log.create({
data: {
meta: Prisma.DbNull,
},
})
We recommend you double-check queries that use Json after upgrading to Prisma 4. Ensure that you use the Prisma.DbNull, Prisma.JsonNull, and Prisma.AnyNull constants from Prisma Client, not string literals.
Refer to the Prisma 4 upgrade guide in case you run into any type errors.
We've refined the experience when working with Prisma Studio with the following changes:
The minimum version of Node.js Prisma will support is 14.17.x. If you're using an earlier version of Node.js, you will need to update your Node.js version.
Refer to our system requirements for the minimum versions Prisma requires
We had inconsistent and large default values (500 for PostgreSQL and 1000 for MySQL) for the statement_cache_size. The new shared default value is 100.
If the new default doesn't work for you, please create an issue and use the statement_cache_size=x parameter in your connection string to override the default value.
@prisma/sdk npm package to @prisma/internalsThe internal package @prisma/sdk is now available under the new, more explicit name @prisma/internals.
We do not provide any API guarantees for @prisma/internals as it might need to introduce breaking changes from time to time, and it does not follow semantic versioning.
This is technically not a breaking change as usage of the @prisma/sdk package is neither documented nor supported.
If you're using @prisma/sdk (now @prisma/internals), it would be helpful if you could help us understand where, how, and why you are using it by giving us feedback in this GitHub discussion. Your feedback will be valuable to us in defining a better API.
schema property from the generated Prisma ClientWe've removed the internal Prisma.dmmf.schema to reduce the size of Prisma Client generated and improve boot times.
To access the schema property, you can use the getDmmf() method from @prisma/internals.
<details> <summary> Prisma </summary>
statement_cache_sizetype alias with Prisma 4.0.0@unique is added during Re-Introspectionreferences arg on Many2Many relations on SQLextendedIndexes GAextendedIndexesOption::unwrap() on a None value in query-engine/core/src/interpreter/query_interpreters/nested_read.rs:232:50db pull / db push flowdb push with MongoDBlength prefix on Unsupported fields on MySQLundici 5.1.1 package</details>
<details> <summary> Prisma Client </summary>
PrismaClientInitializationError is missing expected error codeResult::unwrap() on an Err value: FieldNotFound { name: "upsert", model: "CcStructureUnit" } in query-engine/core/src/query_graph_builder/write/write_args_parser.rs:24:62@prisma/sdk package to reduce confusionsqlite: for defining a sqlite urlOption::unwrap() on a None value in query-engine/core/src/interpreter/query_interpreters/nested_read.rs:232:50Option::unwrap() on a None value in query-engine\core\src\interpreter\query_interpreters\nested_read.rs:232:50thread 'tokio-runtime-worker' panicked at 'called Option::unwrap()on aNone value', /Users/runner/.cargo/git/checkouts/quaint-9f01e008b9a89c14/479e08a/src/connector/postgres/conversion/decimal.rs:81:39default(now()) on the same table sometimes yield different times</details>
<details> <summary> Language tools (e.g. VS Code) </summary>
<details> <summary> Prisma Engines</summary>
Huge thanks to @shian15810, @zifeo, @ever0de, @givensuman, @peter-gy, @rushabhhere, @flatplate, @njmaeff, @tnzk, @DePasqualeOrg, @roboncode, @jacobhq for helping!
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" livestream.
The stream takes place on YouTube on Thursday, June 30 at 5 pm Berlin | 8 am San Francisco.
We're going to host a dedicated webinar with Prisma engineers to talk about the upgrade process. If you're unsure whether the breaking changes of this release affect you, be sure to not miss this livestream.
The stream takes place on YouTube on Tuesday, July 12 at 5 pm Berlin | 8 am San Francisco.
Nothing published for this version