@prisma/adapter-d1
7.10.1 · 15 Oct 2026Apache-2.073.1k / weekRepositorynpmAtom feed
74 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.
- 6.x
6.0.0
28 Nov 2024- breaking
For Node.js 18 the minimum supported version is 18.18.0
- breaking
For Node.js 20 the minimum supported version is 20.9.0
- breaking
For Node.js 22 the minimum supported version is 22.11.0
We’re excited to share the Prisma ORM v6 release today 🎉
As this is a major release, it includes a few breaking changes that may affect your application. Before upgrading, we recommend that you check out our upgrade guide to understand the impact on your application.
If you want to have an overview of what we accomplished since v5, check out our announcement blog post: Prisma 6: Better Performance, More Flexibility & Type-Safe SQL.
🌟 Help us spread the word about Prisma by starring the repo ☝️ or posting on X about the release.
Breaking changes
⚠️ This section contains a list of breaking changes. If you upgrade your application to Prisma ORM v6 without addressing these, your application is going to break! For detailed upgrade instructions, check out the upgrade guide. ⚠️
Minimum supported Node.js versions
The new minimum supported Node.js versions for Prisma ORM v6 are:
- breaking
For Node.js 18 the minimum supported version is 18.18.0
- breaking
For Node.js 20 the minimum supported version is 20.9.0
- breaking
For Node.js 22 the minimum supported version is 22.11.0
There is no official support for Node.js <18.18.0, 19, 21, 23.
Minimum supported TypeScript version
The new minimum supported TypeScript version for Prisma ORM v6 is: 5.1.0.
Schema change for implicit m-n relations on PostgreSQL
If you're using PostgreSQL and are defining implicit many-to-many relations in your Prisma schema, Prisma ORM maintains the relation table for you under the hood. This relation table has
AandBcolumns to represent the tables of the models that are part of this relation.Previous versions of Prisma ORM used to create a unique index on these two columns. In Prisma v6, this unique index is changing to a primary key in order to simplify for the default replica identity behaviour.
If you're defining implicit m-n relations in your Prisma schema, the next migration you'll create will contain
ALTER TABLEstatements for all the relation tables that belong to these relations.Full-text search on PostgreSQL
The
fullTextSearchPreview feature is promoted to General Availability only for MySQL. This means that if you're using PostgreSQL and currently make use of this Preview feature, you now need to use the newfullTextSearchPostgresPreview feature.Usage of
BufferPrisma v6 replaces the usage of
BufferwithUint8Arrayto represent fields of typeBytes. Make sure to replace all your occurrences of theBuffertype with the newUint8Array.Removed
NotFoundErrorIn Prisma v6, we removed the
NotFoundErrorin favor ofPrismaClientKnownRequestErrorwith error codeP2025infindUniqueOrThrow()andfindFirstOrThrow(). If you've relied on catchingNotFoundErrorinstances in your code, you need to adjust the code accordingly.New keywords that can't be used as model names:
async,await,usingWith this release, you can't use
async,awaitandusingas model names any more.⚠️ For detailed upgrade instructions, check out the upgrade guide. ⚠️
Preview features promoted to General Availability
In this release, we are promoting a number of Preview features to General Availability.
fullTextIndexIf you use the full-text index feature in your app, you can now remove
fullTextIndexfrom thepreviewFeaturesin your Prisma schema:generator client { provider = "prisma-client-js" - previewFeatures = ["fullTextIndex"] }fullTextSearchIf you use the full-text search feature with MySQL in your app, you can now remove
fullTextSearchfrom thepreviewFeaturesin your Prisma schema:generator client { provider = "prisma-client-js" - previewFeatures = ["fullTextSearch"] }If you are using it with PostgreSQL, you need to update the name of the feature flag to
fullTextSearchPostgres:generator client { provider = "prisma-client-js" - previewFeatures = ["fullTextSearch"] + previewFeatures = ["fullTextSearchPostgres"] }New features
We are also releasing new features with this release:
Company news
Prisma Postgres is free during Early Access
In case you missed it: We recently launched Prisma Postgres, a serverless database with zero cold starts, a generous free tier, connection pooling, real-time events, and a lot more! It’s entirely free during the Early Access phase, try it now!
Let us know what you think of Prisma ORM
We're always trying to improve! If you've recently used Prisma ORM, we'd appreciate hearing your thoughts about your experience via this 2min survey.
- 5.x
5.22.0
5 Nov 2024Today, we are excited to share the
5.22.0stable release 🎉🌟 Help us spread the word about Prisma by starring the repo ☝️ or posting on X about the release.
Highlights
Further Tracing Improvements
In our ongoing effort to stabilize the
tracingPreview feature, we’ve made our spans compliant with OpenTelemetry Semantic Conventions for Database Client Calls. This should lead to better compatibility with tools such as DataDog and Sentry.We’ve also included numerous bug fixes that should make this Preview feature easier to work with.
Metrics bug fix
Occasionally, connection pool metrics would become negative or grow unbounded. In this release, connection pool metrics should stay consistent.
Connection Pool Timeout fix
In a specific case, there could be issues where fetching a new connection from the connection pool would time out, regardless of the state of the application and connection pool. If you have experience connection pool issues accessing a PostgreSQL database with TLS encryption in a resource-constrained environment (such as Function-as-a-Service offerings or very small VPS) this should resolve those issues.
Special thanks to @youxq for their pull request and help resolving this issue!
Join us
Looking to make an impact on Prisma in a big way? We're hiring!
Learn more on our careers page: prisma.io/careers
Fixes and improvements
Prisma Migrate
Prisma
5.21.1
17 Oct 2024Fixed a bug where migrations were not using shadow database correctly in some edge cases
5.21.0
15 Oct 2024Today, we are excited to share the
5.21.0release 🎉🌟 Help us spread the word about Prisma by starring the repo ☝️ or posting on X about the release.
Highlights
Better support for tracing in MongoDB
The
tracingPreview feature now has full support for MongoDB with previously missing functionality now implemented. This is a part of the ongoing effort to stabilize this Preview feature and release it in General Availability.tracingis a Preview feature that enables built-in support for OpenTelemetry instrumentation inside the Prisma Client and provides deep insights into the performance and timing of your queries. See our documentation for more information.For an easy to use and zero-configuration tracing instrumentation tool with a dashboard that provides an overview of your queries, statistics, and AI-powered recommendations, try Prisma Optimize.
WebAssembly engine size decrease for edge functions
Due to recent changes, some users experienced a steep increase of the bundle size in Prisma 5.20 when using the
driverAdaptersPreview feature, going over the 1 MB limit on the free tier of Cloudflare Workers. This has now been fixed.Fixes and improvements
Prisma Engines
5.20.0
24 Sep 2024🌟 Help us spread the word about Prisma by starring the repo or posting on X about the release. 🌟
Highlights
strictUndefinedChecksin PreviewWith Prisma ORM 5.20.0, the Preview feature
strictUndefinedCheckswill disallow any value that is explicitlyundefinedand will be a runtime error. This change is direct feedback from this GitHub issue and follows our latest proposal on the same issue.To demonstrate the change, take the following code snippet:
prisma.table.deleteMany({ where: { // If `nullableThing` is nullish, this query will remove all data. email: nullableThing?.property, } })In Prisma ORM 5.19.0 and below, this could result in unintended behavior. In Prisma ORM 5.20.0, if the
strictUndefinedChecksPreview feature is enabled, you will get a runtime error instead:Invalid \`prisma.user.findMany()\` invocation in /client/tests/functional/strictUndefinedChecks/test.ts:0:0 XX }) XX XX test('throws on undefined input field', async () => { → XX const result = prisma.user.deleteMany({ where: { email: undefined ~~~~~~~~~ } }) Invalid value for argument \`where\`: explicitly \`undefined\` values are not allowed."We have also introduced the
Prisma.skipsymbol, which will allow you to get the previous behavior if desired.prisma.table.findMany({ where: { // Use Prisma.skip to skip parts of the query email: nullableEmail ?? Prisma.skip } })From Prisma ORM 5.20.0 onward, we recommend enabling
strictUndefinedChecks, along with the TypeScript compiler optionexactOptionalPropertyTypes, which will help catch cases of undefined values at compile time. Together, these two changes will help protect your Prisma queries from potentially destructive behavior.strictUndefinedCheckswill be a valid Preview feature for the remainder of Prisma ORM 5. With our next major version, this behavior will become the default and the Preview feature will be “graduated” to Generally Available.If you have any questions or feedback about
strictUndefinedChecks, please ask/comment in our dedicated Preview feature GitHub discussion.typedSqlbug fixThank you to everyone who has tried out our
typedSqlPreview feature and provided feedback! This release has a quick fix for typescript files generated when Prisma Schema enums had hyphens.Fixes and improvements
Prisma
Prisma incorrectly parses CRDB's FK constraint error as
not available.Invalid TypeScript files created by
generatewhen typedSql is enabled and enum contains hyphens.using
$extendsprevents model comments from being passed to TypeScript
Prisma Engines
5.19.1
2 Sep 2024Today, we are issuing the
5.19.1patch release.Today, we are issuing the
5.19.1patch release.What's Changed
We've fixed the following issues:
5.19.0
27 Aug 2024Make sure that you have the latest version of
prismaand@prisma/clientinstalled:npm install -D prisma@latest npm install @prisma/client@latest
Enable the
typedSqlPreview feature in your Prisma Schema.generator client { provider = "prisma-client-js" previewFeatures = ["typedSql"] }Create a
sqlsubdirectory of yourprismadirectory.mkdir -p prisma/sql
Today, we are excited to share the
5.19.0stable release 🎉🌟 Help us spread the word about Prisma by starring the repo or posting on X about the release. 🌟
Highlights
Introducing TypedSQL
TypedSQL is a brand new way to interact with your database from Prisma Client. After enabling the
typedSqlPreview feature, you’re able to write SQL queries in a newsqlsubdirectory of yourprismadirectory. These queries are then checked by Prisma during using the new--sqlflag ofprisma generateand added to your client for use in your code.To get started with TypedSQL:
Make sure that you have the latest version of
prismaand@prisma/clientinstalled:npm install -D prisma@latest npm install @prisma/client@latest
Enable the
typedSqlPreview feature in your Prisma Schema.generator client { provider = "prisma-client-js" previewFeatures = ["typedSql"] }Create a
sqlsubdirectory of yourprismadirectory.mkdir -p prisma/sql
You can now add
.sqlfiles to thesqldirectory! Each file can contain one sql query and the name must be a valid JS identifier. For this example, say you had the filegetUsersWithPosts.sqlwith the following contents:SELECT u.id, u.name, COUNT(p.id) as "postCount" FROM "User" u LEFT JOIN "Post" p ON u.id = p."authorId" GROUP BY u.id, u.name
Import your SQL query into your code with the
@prisma/client/sqlimport:import { PrismaClient } from '@prisma/client' import { getUsersWithPosts } from '@prisma/client/sql' const prisma = new PrismaClient() const usersWithPostCounts = await prisma.$queryRawTyped(getUsersWithPosts) console.log(usersWithPostCounts)
There’s a lot more to talk about with TypedSQL. We think that the combination of the high-level Prisma Client API and the low-level TypedSQL will make for a great developer experience for all of our users.
To learn more about behind the “why” of TypedSQL be sure to check out our announcement blog post.
For docs, check out our new TypedSQL section.
Bug fixes
Driver adapters and D1
A few issues with our
driverAdaptersPreview feature and Cloudflare D1 support were resolved via #4970 and #24922Mathematic operations such as
max,min,eq, etc in queries when using Cloudflare D1.Resolved issues when comparing
BigIntIDs whenrelationMode="prisma"was enabled and Cloudflare D1 was being used.
Joins
#23742 fixes Prisma Client not supporting deeply nested
someclauses when therelationJoinsPreview feature was enabled.
MongoDB
The MongoDB driver for Rust (that our query engine users under the hood) had behavior that prioritized IPv4 connections over IPv6 connections. In IPv6-only environments, this could lead to significant "cold starts" where the query engine had to wait for IPv4 to fail before the driver would try IPv6.
With help from the MongoDB team, this has been resolved. The driver will now try IPv4 and IPv6 connections in parallel and then move forward with the first response. This should prevent cold start issues that have been seen with MongoDB in Prisma Accelerate.
Thank you to the MongoDB team!
Join us
Looking to make an impact on Prisma in a big way? We're now hiring engineers for the ORM team!
Senior Engineer (TypeScript): This person will be primarily working on the TypeScript side and evolving our Prisma client. Rust knowledge (or desire to learn Rust) is a plus.
Senior Engineer (Rust): This person will be focused on the
prisma-enginesRust codebase. TypeScript knowledge (or, again, a desire to learn) is a plus.
5.18.0
6 Aug 2024[Empty
Jsonfields will now return `` instead ofnullwhen accessed through a join using therelationJoinsPreview feature.](#22923)
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Native support for UUIDv7
Previous to this release, the Prisma Schema function
uuid()did not accept any arguments and created a UUIDv4 ID. While sufficient in many cases, UUIDv4 has a few drawbacks, namely that it is not temporally sortable.UUIDv7 attempts to resolve this issue, making it easy to temporally sort your database rows by ID!
To support this, we’ve updated the
uuid()function in Prisma Schema to accept an optional, integer argument. Right now, the only valid values are4and7, with4being the default.model User { id String @id @default(uuid()) // defaults to 4 name String } model User { id String @id @default(uuid(4)) // same as above, but explicit name String } model User { id String @id @default(uuid(7)) // will use UUIDv7 instead of UUIDv4 name String }Bug squashing
We’ve squashed a number of bugs this release, special thanks to everyone who helped us! A few select highlights are:
SQLite db will now be created and read from the correct location when using
prismaSchemaFolder.[Empty
Jsonfields will now return `` instead ofnullwhen accessed through a join using therelationJoinsPreview feature.](#22923)
Fixes and improvements
Prisma
Language tools (e.g. VS Code)
Share your feedback about Prisma ORM
We want to know how you like working with Prisma ORM in your projects! Please take our 2min survey and let us know what you like or where we can improve 🙏
5.17.0
16 Jul 2024🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
VSCode extension improvements
We’re happy to introduce some cool new features that will make your experience with the Prisma VSCode extension even better!
Find references across schema files
The ability to hop between references of a given symbol is really useful in application code and now with the introduction of multi-file schema, we think it’s the perfect time to bring this feature to the VSCode extension!
With the 5.17.0 release, you’ll now have the ability to use the native “find references” feature to find any usage of a given symbol
references
Added context on hover
When hovering over a symbol that references a view, type, enum, or any other block with multiple values, you’ll now see a handy pop out that shows what is in that block at a glance.
image
Additional quick fixes
We’ve taken some fixes made by the
prisma formatcli command and made them quick fixes available to the VSCode Extension. Now, when you have forget a back relation or relation scalar field, you’ll now see in real time what is wrong and have the option to fix it via the extension.image (1)
QueryRaw performance improvements
We’ve changed the response format of
queryRawto decrease its average size which reduces serialization CPU overhead.When querying large data sets, we expect you to see improved memory usage and up to 2x performance improvements.
Fixes and improvements
Prisma Client
Prisma
Language tools (e.g. VS Code)
5.16.2
9 Jul 2024Today, we are issuing the 5.16.2 patch release to fix an issue in Prisma client.
Fix in Prisma Client
5.16.1
27 Jun 2024Today, we are issuing the 5.16.1 patch release to fix an issue in Prisma client.
Fix in Prisma Client
5.16.0
25 Jun 2024When using relative paths in Prisma Schema files with the
prismaSchemaFolderfeature, a path is now relative to the file it is defined in rather than relative to theprisma/schemafolder. This means that if you have a generator block in/project/prisma/schema/config/generator.prismawith anoutputof./foothe output will be resolved to/project/prisma/schema/config/foorather than/project/prisma/foo. The path to a SQLite file will be resolved in the same manner.We realized that during migration many people would have
prisma/schemaas well asprisma/schema.prisma. Our initial implementation looked for a.prismafile first and would ignore theschemafolder if it exists. This is now an error.
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Omit model fields globally
With Prisma ORM 5.16.0 we’re more than happy to announce that we’re expanding the
omitApiPreview feature to also include the ability to omit fields globally.When the Preview feature is enabled, you’re able to define fields to omit when instantiating Prisma Client.
const prisma = new PrismaClient({ omit: { user: { // make sure that password is never queried. password: true, }, }, });You’re also able to omit fields from multiple models and multiple fields from the same model
const prisma = new PrismaClient({ omit: { user: { // make sure that password and internalId are never queried. password: true, internalId: true, }, post: { secretkey: true, }, }, });With both local and global
omit, you now have the flexibility to completely remove sensitive fields while also tailoring individual queries. If you need the ability to generally omit a field except in a specific query, you can also overwrite a global omit locallyconst prisma = new PrismaClient({ omit: { user: { // password is omitted globally. password: true, }, }, }); const userWithPassword = await prisma.user.findUnique({ omit: { password: false }, // omit now false, so password is returned where: { id: 1 }, });Changes to
prismaSchemaFolderIn
5.15.0we released theprismaSchemaFolderPreview feature, allowing you to create multiple Prisma Schema files in aprisma/schemadirectory. We’ve gotten a lot of great feedback and are really excited with how the community has been using the feature.To continue improving our multi-file schema support, we have a few breaking changes to the
prismaSchemaFolderfeature:When using relative paths in Prisma Schema files with the
prismaSchemaFolderfeature, a path is now relative to the file it is defined in rather than relative to theprisma/schemafolder. This means that if you have a generator block in/project/prisma/schema/config/generator.prismawith anoutputof./foothe output will be resolved to/project/prisma/schema/config/foorather than/project/prisma/foo. The path to a SQLite file will be resolved in the same manner.We realized that during migration many people would have
prisma/schemaas well asprisma/schema.prisma. Our initial implementation looked for a.prismafile first and would ignore theschemafolder if it exists. This is now an error.
Changes to
fullTextSearchIn order to improve our full-text search implementation we have made a breaking change to the
fullTextSearchPreview feature.Previously, when the feature was enabled we updated the
<Model>OrderByWithRelationInputTypeScript type with the<Model>OrderByWithRelationAndSearchRelevanceInputtype. However, we have noted that there are no cases where relational ordering is needed but search relevance is not. Thus, we have decided to remove the<Model>OrderByWithRelationAndSearchRelevanceInputnaming and only use the<Model>OrderByWithRelationInputnaming.Fixes and improvements
Prisma
[Driver Adapters]: missing provider compatibility validation
Disable "Start using Prisma Client" hint logs on
prisma generate@prisma/adapter-pgmodifies node-postgres global type parsers@prisma/adapter-d1 is failing with an import error when called inside vitest tests
Language tools (e.g. VS Code)
Prisma Engines
5.15.1
18 Jun 2024Today, we are issuing the
5.15.1patch release.Fixes in Prisma Client
Got error 'internal error: entered unreachable code' when trying to perform an upsert.
ConnectionError(Timed out during query execution.)during seedingConnectionError(Timed out during query execution.)error when usingPromise.allfor SQLiteSQLite times out during query execution when using
Promise.all()/ concurrent
5.15.0
4 Jun 2024Enable the
prismaSchemaFolderPreview feature by including it in thepreviewFeaturesfield of yourgenerator.datasource db { provider = "postgresql" url = env("DATABASE_URL") } generator client { provider = "prisma-client-js" previewFeatures = ["prismaSchemaFolder"] }Create a
schemasubdirectory under yourprismadirectory.
Today, we are excited to share the
5.15.0stable release 🎉🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Multi-File Prisma Schema support
Prisma ORM 5.15.0 features support for multi-file Prisma Schema in Preview.
This closes a long standing issue and does so in a clean and easy to migrate way.
To get started:
Enable the
prismaSchemaFolderPreview feature by including it in thepreviewFeaturesfield of yourgenerator.datasource db { provider = "postgresql" url = env("DATABASE_URL") } generator client { provider = "prisma-client-js" previewFeatures = ["prismaSchemaFolder"] }Create a
schemasubdirectory under yourprismadirectory.Move your
schema.prismainto this directory.
You are now set up with a multi-file Prisma Schema! Add as many or as few
.prismafiles to the newprisma/schemadirectory.When running commands where a Prisma Schema file is expected to be provided, you can now define a Prisma Schema directory. This includes Prisma CLI commands that use the
--schemaoption as well as defining schema viapackage.jsonOur tooling has also been updated to handle multiple Prisma Schema files. This includes our Visual Studio Code extension and tools like database introspection, which will deposit new models in a
introspected.prismafile. Existing models will be updated in the file they are found.To learn more, please refer to our official documentation and announcement blog post. If you try out
prismaSchemaFolder, please let us know!Interesting Bug Fixes
Fix for PostgreSQL prepared statement caching for raw queries
This release fixes a nasty bug with the caching of prepared statements in raw Prisma Client queries that affected PostgreSQL when you ran the same SQL statement with differently typed paramters. This should not fail any more.
Fix for SQL Server introspection of (deprecated)
CREATE DEFAULTOur Introspection logic crashed on encountering certain multi-line
CREATE DEFAULT, a deprecated way to define defaults in SQL Server. As many SQL Server users are working with established databases, this happened frequently enough that we now explicitly ignore these defaults instead of crashing.Fix for Cloudflare D1’s lower parameter limit
Cloudflare’s D1 has a lower parameter limit than local SQLite, which caused bigger queries to fail. We adapted that limit to the D1 default for
@prisma/adapter-d1, which will avoid such failures.Fix for Cloudflare D1’s different
PRAGMAsupportOur generated migration SQL for SQLite did not always work for Cloudflare D1, because of differences in the supported pragmas. We adapted the SQL to work in both local SQLite and Cloudflare D1.
Fixes and improvements
Prisma Migrate
doing introspection on a SQL Server 2018 DB - for Dynamic GP get the following error.
Error: called
Result::unwrap()on anErrvalue: "Couldn't parse default value in SQL ServerSQL Server Introspection crashes on multi-line (deprecated) defaults
Prisma Client
Float number on raw query:
incorrect binary data format in bind parameter 1Can't use Prisma client in Next.js middleware, even when deploying to Node.js
Next.js app build fails when using Prisma with DB driver in Server Action
Bug: [D1] Error in performIO: Error: D1_ERROR: too many SQL variables
$executeRawUnsafe:
incorrect binary data format in bind parameter 6Bug: Error or bug using Prisma with DriverAdapter with PostgreSQL database Neon
Incompatibility with NextJS app dir, CloudFlare Pages and D1
- breaking
Language tools (e.g. VS Code)
5.14.0
14 May 2024Today, we are excited to share the
5.14.0stable release 🎉🌟 Help us spread the word about Prisma by starring the repo ☝️ or posting on X about the release. 🌟
Highlights
Share your feedback about Prisma ORM
We want to know how you like working with Prisma ORM in your projects! Please take our 2min survey and let us know what you like or where we can improve 🙏
createManyAndReturn()We’re happy to announce the availability of a new, top-level Prisma Client query:
createManyAndReturn(). It works similarly tocreateMany()but uses aRETURNINGclause in the SQL query to retrieve the records that were just created.Here’s an example of creating multiple posts and then immediately returning those posts.
const postBodies = req.json()['posts'] const posts = prisma.post.createManyAndReturn({ data: postBodies }); return postsAdditionally,
createManyAndReturn()supports the same options asfindMany(), such as the ability to return only specific fields.const postBodies = req.json()['posts'] const postTitles = prisma.post.createManyAndReturn({ data: postBodies, select: { title: true, }, }); return postTitlesFull documentation for this feature can be found in the Prisma Client API Reference.
Note: Because
createManyAndReturn()uses theRETURNINGclause, it is only supported by PostgreSQL, CockroachDB, and SQLite databases. At this time,relationLoadStrategy: joinis not supported increateManyAndReturn()queries.MongoDB performance improvements
Previously, Prisma ORM suffered from performance issues when using the
inoperator or when including related models in queries against a MongoDB database. These queries were translated by the Prisma query engine in such a way that indexes were skipped and collection scans were used, leading to slower queries especially on large datasets.With 5.14.0, Prisma ORM now rewrites queries to use a combination of
$orand$eqoperators, leading to dramatic performance increases for queries that includeinoperators or relation loading.Fixes and improvements
Prisma Client
MongoDB: Performance issue with nested
takeon many-to-one relationship[MongoDB] Performance issue in
findMany()query execution withinMongoDB Connector generates queries which do not take advantage of indices.
Prisma Migrate
Validation error when
shadowDatabaseUrlis identical tourl(ordirectUrl)MongoDB Query with 'in' condition will cause COLLSCAN, without leveraging indexes
Language tools (e.g. VS Code)
Company news
Prisma Changelog
Curious about all things Prisma? Be sure to check out the Prisma Changelog for updates across Prisma's products, including ORM, Accelerate, and Pulse!
New product announcement: Prisma Optimize
With this release, we are excited to introduce a new Prisma product. We’re calling it “Optimize” because that’s what it does! Let your favorite ORM also help you debug the performance of your application.
Check out our announcement blog post for more details, including a demo video.
5.13.0
23 Apr 2024Today, we are excited to share the
5.13.0stable release 🎉🌟 Help us spread the word about Prisma by starring the repo or posting on X about the release.
Highlights
omitfields from Prisma Client queries (Preview)We’re excited to announce Preview support for the
omitoption within the Prisma Client query options. The highly-requestedomitfeature now allows you to exclude fields that you don’t want to retrieve from the database on a per-query basis.By default, when a query returns records, the result includes all scalar fields of the models defined in the Prisma schema.
selectcan be used to return specific fields, whileomitcan now be used to exclude specific fields.omitlives at the same API level and works on all of the same Prisma Client model queries asselect. Note, however, thatomitandselectare mutually exclusive. In other words, you can’t use both in the same query.To get started using
omit, enable theomitApiPreview feature in your Prisma schema:// schema.prisma generator client { provider = "prisma-client-js" previewFeatures = ["omitApi"] }Be sure to re-generate Prisma Client afterwards:
npx prisma generate
Here is an example of using
omit:// Includes all fields except password await prisma.user.findMany({ omit: { password: true }, })Here is an example of using
omitwithinclude:// Includes all user fields except user's password and title of user's posts await prisma.user.findMany({ omit: { password: true }, include: { posts: { omit: { title: true }, }, }, })Expand to view the example Prisma schema
model User { id Int @id @default(autoincrement()) email String @unique name String? password String posts Post[] } model Post { id Int @id @default(autoincrement()) title String author User @relation(fields: [authorId], references: [id]) authorId Int }Many users have requested a global implementation of
omit. This request will be accommodated in the future. In the meantime, you can follow the issue here.📣 Share your feedback:
omitApiPreview feature📚 Documentation:
omit- Prisma Client API ReferenceFixes and improvements
Prisma Migrate
Prisma Client
MySQL
upsert():Internal error: Attempted to serialize empty result.Mysql
upsert()fails with "Attempted to serialize empty result."Interactive Transaction API timing out after upgrading from 4.7.0 and above
MySQL and SQLite
upsert():Internal error: Attempted to serialize empty result.MySQL
upsert():Internal error: Attempted to serialize empty result.MongoDB
upsert():Internal error: Attempted to serialize empty result.MongoDB
upsert():Internal error: Attempted to serialize empty resultRelation mode +
upsert():Internal error: Attempted to serialize empty result.
5.12.1
4 Apr 2024Today, we are issuing the
5.12.1patch release to fix two small problems with our new Cloudflare D1 support.Fixes in Prisma CLI
Windows-only fix for new D1 specific flags for
migrate diffanddb pullThe flags
--from-local-d1and--to-local-d1formigrate diffand--local-d1todb pullwe added in 5.12.0 were not working as expected when running on Windows only. This is now fixed.📚 Documentation: Deploying a Cloudflare worker with D1 and Prisma ORM
New option for
migrate diff:-oor--outputWe added a new parameter
--outputtomigrate diffthat can be used to provide a filename into which the output of the command will be written. This is particularly useful for Windows users, using PowerShell, as using>to write into a file creates a UTF-16 LE file that can not be read bywrangler d1 migrations apply. Using this new option, this problem can be avoided:npx prisma migrate diff --script --from-empty --to-schema-datamodel ./prisma/schema.prisma --output ./schema.sql
Related issues:
5.12.0
2 Apr 2024Today, we are excited to share the
5.12.0stable release 🎉🌟 Help us spread the word about Prisma by starring the repo or posting on X about the release.
Highlights
Cloudflare D1 (Preview)
This release brings Preview support for Cloudflare D1 with Prisma ORM 🥳
D1 is Cloudflare’s SQLite database that can be used when deploying applications with Cloudflare.
When using Prisma ORM with D1, you can continue to: model your database with Prisma schema language, specify
sqliteas your database provider in your Prisma schema, and interact with your database using Prisma Client.To use Prisma ORM and D1 on Cloudflare Workers or Cloudflare Pages, you need to set
sqliteas your database provider and use the@prisma/adapter-d1database adapter via thedriverAdaptersPreview feature, released back in version 5.4.0.Here is an example of sending a query to your D1 database using Prisma Client in your Worker:
// src/index.ts file import { PrismaClient } from '@prisma/client' import { PrismaD1 } from '@prisma/adapter-d1' // Add the D1Database to the Env interface export interface Env { // This must match the binding name defined in your wrangler.toml configuration DB: D1Database } export default { async fetch( request: Request, env: Env, ctx: ExecutionContext ): Promise<Response> { // Make sure the database name matches the binding name in wrangler.toml and Env interface const adapter = new PrismaD1(env.DB) // Instantiate PrismaClient using the PrismaD1 driver adapter const prisma = new PrismaClient({ adapter }) const users = await prisma.user.findMany() const result = JSON.stringify(users) return new Response(result) }, }📚 Documentation: D1 Documentation
✍️ Blog post: Build Applications at the Edge with Prisma ORM & Cloudflare D1 (Preview)
📣 Share your feedback: D1 Driver Adapter
🚀 Example project: Deploy a Cloudflare Worker with D1
createMany()for SQLiteBringing support for
createMany()in SQLite has been a long-awaited feature ⭐createMany()is a method on Prisma Client, released back in version 2.16.0, that lets you insert multiple records into your database at once. This can be really useful when seeding your database or inserting bulk data.Here is an example of using
createMany()to create new users:const users = await prisma.user.createMany({ data: [ { name: 'Sonali', email: 'sonali@prisma.io' }, { name: 'Alex', email: 'alex@prisma.io' }, { name: 'Yewande', email: 'yewande@prisma.io' }, { name: 'Angelina', email: 'angelina@prisma.io' }, ], })Before this release, if you wanted to perform bulk inserts with SQLite, you would have most likely used
$queryRawUnsafeto execute raw SQL queries. But now you don’t have to go through all that trouble 🙂With SQLite,
createMany()works exactly the same way from an API standpoint as it does with other databases except it does not support theskipDuplicatesoption. At the behavior level, SQLite will splitcreateMany()entries into multipleINSERTqueries when the model in your schema contains fields with attributes like@default(dbgenerated())or@default(autoincrement())and when the fields are not consistently provided with values across the entries.📚Documentation:
createMany()- Prisma Client API ReferenceFixes and Improvements
Prisma Client
5.11.0
12 Mar 2024Vercel Edge Functions and Vercel Edge Middleware
Cloudflare Workers and Cloudflare Pages
Neon Serverless Driver (for PostgreSQL databases hosted via Neon)
Today, we are excited to share the
5.11.0stable release 🎉🌟 Help us spread the word about Prisma by starring the repo ☝️ or posting on X about the release.
Highlights
Edge function support for Cloudflare and Vercel (Preview)
We’re thrilled to announce that support for edge function deployments with Prisma ORM is now in Preview 🥳 As of this release, you can deploy your apps that are using Prisma ORM to:
Vercel Edge Functions and Vercel Edge Middleware
Cloudflare Workers and Cloudflare Pages
In order to deploy to an edge function, you’ll need to use a compatible database driver (along with its Prisma driver adapter):
Neon Serverless Driver (for PostgreSQL databases hosted via Neon)
PlanetScale Serverless Driver (for MySQL databases hosted via PlanetScale)
pgdriver (for traditional PostgreSQL databases)@libsql/clientdriver (for SQLite databases hosted via Turso)
Check out our documentation to learn how you can deploy an edge function using any combination of supported edge function provider and database.
You can also read more about it in the announcement blog post!
Performance improvements in nested
createoperationsWith Prisma ORM, you can create multiple new records in nested queries, for example:
const user = await prisma.user.update({ where: { id: 9 }, data: { name: 'Elliott', posts: { create: { data: [{ title: 'My first post' }, { title: 'My second post' }], }, }, }, })In previous versions, Prisma ORM would translate this into multiple SQL
INSERTqueries, each requiring its own roundtrip to the database. As of this release, these nestedcreatequeries are optimized and theINSERTqueries are sent to the database in bulk in a single roundtrip. These optimizations apply to one-to-many as well as many-to-many relations.With this change, using the nested
createoption to create multiple records effectively becomes equivalent to using a nestedcreateManyoperation (except thatcreateManyonly works with one-to-many relations, whereascreateworks both with one-to-many and many-to-many).Note: Only the deepest nested operation is optimized. If a user specified
create (1) -> create (2) -> create (3)in their query, onlycreate (3)will be optimized.Fixes and improvements
Prisma Client
Prisma errors when not using the major.minor.patch versioning system
mongodb where condition resulted in combined $ne but should not be $eq
Regression: Mapped
enumthrows error (collationcp1250_czech_csor similar)Running
prisma generateon Litespeed Web Server cPanel with sshPrisma doesn't know which engines to download for the Linux distro "guttaos"
Error in driver-adapter-utils with
tsc:Cannot find namespace 'debug'.VS Code debugger freeze from time to time, when Prisma Client is involved
pushmethod still unimplemented for scalar lists in CockroachDB
Prisma Migrate
Error when run
npx prisma db pullwith DeepinOS 20.9GNU/LInuxPrisma doesn't know which engines to download with
Linux MintError: Invalid characterwhenschema.prismaincludes Chinese/Non-ASCII characters in a comment
Prisma Engines
5.10.2
21 Feb 2024Today, we are issuing the
5.10.2patch release.Fix in Prisma CLI
5.10.1
20 Feb 2024Today, we are issuing the
5.10.1patch release.Fix in Prisma Client / Prisma CLI
5.10.0
20 Feb 2024join(default): Sends a single query to the database and joins the data on the database-level.query: Sends multiple queries to the database and joins the data on the application-level.relationLoadStrategyis supported for MySQL v8.0.14 and higher. MariaDB is not supported.
Today, we are excited to share the
5.10.0stable release 🎉🌟 Help us spread the word about Prisma by starring the repo ☝️ or posting on X about the release.
Highlights
Optimized relation queries in MySQL (Preview)
This release brings the optimizations for relation queries from the previous releases to MySQL as well! This means that by enabling the
relationJoinsPreview feature with themysqldatabase provider, you now also get access to therelationLoadStrategyoption in relation queries that let you choose whether you want to merged relations on the application- or database-level.If you enable the
relationJoinsPreview feature, you can choose between thejoinandqueryoptions:join(default): Sends a single query to the database and joins the data on the database-level.query: Sends multiple queries to the database and joins the data on the application-level.
To get started, enable the Preview feature in your Prisma schema:
// schema.prisma generator client { provider = "prisma-client-js" previewFeatures = ["relationJoins"] }Be sure to re-generate Prisma Client afterwards:
npx prisma generate
And finally, specify the relation loading strategy for your relation query via the
relationLoadStrategyoption as follows:await prisma.user.findMany({ relationLoadStrategy: 'join', // or 'query' include: { posts: true, }, })Note that in the example above, the
relationLoadStrategycould be omitted altogether becausejoinis used as the default value.A few notes about
relationLoadStrategysupport on MySQL:relationLoadStrategyis supported for MySQL v8.0.14 and higher. MariaDB is not supported.Prisma ORM uses correlated sub-queries for MySQL (as opposed to
LATERALJOINs which are used on PostgreSQL).
Configure transaction options in the
PrismaClientconstructorThis feature enables you to configure the following transaction options on a global level via the
PrismaClientconstructor:isolationLevel: Sets the transaction isolation level. By default, this is set to the value currently configured in your database.timeout: The maximum amount of time the interactive transaction can run before being canceled and rolled back. The default value is 5 seconds.maxWait: The maximum amount of time Prisma Client will wait to acquire a transaction from the database. The default value is 2 seconds.
Here is an example of how you can set this value globally for all transactions:
const prisma = new PrismaClient({ transactionOptions: { isolationLevel: 'ReadCommitted', timeout: 1_000, // 1 sec maxWait: 2_000 // 2 sec } })Thanks a lot to our fantastic community member
@tockn, who took the initiative to implement this feature in Prisma ORM 🎉Note that you can still override the global values by setting them on a particular transaction.
New
P2037code for “Too many database connections opened” errorsWe introduced a new error code for “Too many database connections opened” errors:
P2037. You can find all error codes in our documentation.Access the Prisma Data Platform via Prisma CLI
Now available in Early Access, you can manage your workspace and configure Prisma Accelerate and Prisma Pulse directly from the terminal.
Visit our docs to learn more about the integration and try it out for yourself!
Fixes and improvements
Prisma Client
[5.9.0 Bug]
Prisma.TransactionClientappears to be missing typesv5.9.0 / Don't generate type. And the error from the previous version is still there
relationJoins: "The column
t3.bookGenreTitledoes not exist in the current database"relationJoinspreview feature: calledOption::unwrap()on aNonevalue
5.9.1
1 Feb 2024Today, we are issuing the
5.9.1patch release.Fixes in Prisma Client
In
5.9.0we have changed our conditional exports in@prisma/client. This resulted in broken types for TypesScript users using certain combinations ofmodule/moduleResolutionsettings. Additionally, it also caused a regression for Next.js users which have encountered invalid error messages from our side.You can now try out
5.9.1and let us know if you find a bug at pris.ly/prisma-prisma-bug-reportv5.9.0 / Don't generate type. And the error from the previous version is still there #22896
[5.9.0 Bug] Prisma.TransactionClient appears to be missing types #22870
Note: many issues are duplicates.
5.9.0
30 Jan 2024Reading the note…