@prisma/adapter-planetscale
7.10.1 · 15 Oct 2026Apache-2.069.3k / weekRepositorynpmAtom feed
92 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 2024Improve the performance of relation queries by introducing JOINs (see last release).
Support deployment to edge functions (already available in Early Access, you can apply for trying it out by taking our survey).
Today, we are excited to share the
5.9.0stable release 🎉🌟 Help us spread the word about Prisma by starring the repo ☝️ or posting on X about the release.
This release brings a number of small improvements as we continue our work on larger features which you will hear more about in the coming weeks:
Improve the performance of relation queries by introducing JOINs (see last release).
Support deployment to edge functions (already available in Early Access, you can apply for trying it out by taking our survey).
Highlights
Optimized result sets for more efficient queries
We continue our efforts of the performance of Prisma Client queries. In
5.1.0, we introduced theRETURNINGkeyword for several queries on PostrgeSQL and CockroachDB. We now expanded the use ofRETURNINGto SQLite and a broader range of queries for existing databases (e.g.deleteon PostgreSQL and MongoDB). You can learn more about the optimizations of the result sets in these PRs:SQL Server: Return proper error for unreachable database
When trying migrate/introspect a SQL server instance that’s unreachable, Prisma ORM now returns the correct
P1001error instead of failing without an error. Learn more in this PR: SQL Server: Migrate/Introspection engine doesn't return P1001 error for unreachable url.Fixes and improvements
Prisma Client
Nested json is transformed to string when used “$type” key in object
Parallel execution with Promise.all causes P2024 error in version 5.8.0 due to connection limit
Prisma Migrate
SQL Server: Migrate/Introspection engine doesn't return P1001 error for unreachable url
ERROR: column "..." being dropped, try again laterwhen applying migrations with CRDB 23.1
Language tools (e.g. VS Code)
Company news
Test edge functions support in Early Access
Today, the only way how to use Prisma ORM in edge functions (e.g. Cloudflare Workers or Vercel Edge Functions) is by using Prisma Accelerate. However, we are actively working on making Prisma ORM compatible with edge functions natively as well. If you want to become an early tester, you can apply for the private Early Accessing program by taking this survey.
We Transitioned Prisma Accelerate to IPv6 Without Anyone Noticing
Last year, AWS announced the decision to begin charging for IPv4 addresses beginning in February 2024. This move had a major impact on Prisma Accelerate, prompting us to go all-in on IPv6. Learn more in this technical deep dive into how we approached our IPv6 migration, lessons learned, and the outcome for users of Prisma Accelerate.
5.8.1
15 Jan 2024Today, we are issuing the
5.8.1patch release.Fix in Prisma Client
5.8.0
9 Jan 2024join— usesJOINs to fetch relation dataquery— uses separate queries to fetch relation data
🌟 Help us spread the word about Prisma by starring the repo or posting on X about the release. 🌟
Highlights
Happy New Year from your friends at Prisma! 🎊
In the last 4 weeks, we resolved some bugs on the ORM and made some progress on some exciting features that we’re not yet ready to announce. Stay tuned for the upcoming releases, in which we’ll be announcing new features. 😉
relationJoinsimprovements: Relation loading strategy per query (Preview)In version 5.7.0, we released
relationJoinsinto Preview. TherelationJoinsfeature enables support forJOINs for relation queries.This release adds support for the ability to specify the strategy used to fetch relational data per query when the Preview feature is enabled. This will enable you to choose the most efficient strategy for fetching relation data depending on your use case.
You can now load relation data using either of the following strategies:
join— usesJOINs to fetch relation dataquery— uses separate queries to fetch relation data
When the
relationJoinsPreview feature is enabled, by default, the relation fetching strategy used isjoin. You can override the default behavior by using therelationLoadStrategyquery option.To get started, enable the Preview feature:
// schema.prisma generator client { provider = "prisma-client-js" previewFeatures = ["relationJoins"] }… and specify the relation loading strategy for your query as follows:
await prisma.user.findMany({ relationLoadStrategy: 'query', include: { posts: true, }, })Try it out and share your feedback and create a bug report if you encounter any issues.
Survey: Edge functions support
We’re working on bringing Edge function support to Prisma ORM and we would appreciate your input by submitting a response to our survey. By filling out the survey, you will be considered for our Early Access cohort as soon as we have something for you to try out.
Fixes and improvements
Prisma Client
targetandtimestampare undefined ininfoevents in Data Proxy clientWrong types of
timestampanddurationin query events with Data ProxyUsing
citextfields with neon database driver causes conversion error
Prisma Migrate
Language tools (e.g. VS Code)
Company news
A billion queries and counting: Prisma Accelerate
Prisma Accelerate, our global database cache has served over 1 billion queries since its General Availability launch.
We’d like to give a shoutout to our team and everyone who’s been with us on this journey. Stay tuned for some exciting products and features in the pipeline for 2024!
Prisma ORM Ecosystem
Are you building a cool tool, extension, generator, CLI tool or anything else, for Prisma ORM? Let us know.
We would like to learn about it and feature it on our Ecosystem page.
We’re hiring
If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you. Check out our Careers page for open positions.
5.7.1
18 Dec 2023Today, we are issuing the
5.7.1patch release.This patch fixes multiple small problems in our
relationJoinspreview feature. If you ran into problems when testingrelationJoinsbefore, please give it another go with 5.7.1 and share your feedback or create a bug report if you encounter any issues.Fixes in Prisma Client
5.7.0
6 Dec 2023🌟 Help us spread the word about Prisma by starring the repo or posting on X (formerly Twitter) about the release.
Highlights
✨ In this release, we improved the SQL queries Prisma Client generates for you with two new Preview features, the driver adapters, and support for the database drivers we currently support. 5.7.0 will be the last release of the year. Stay tuned for the next one in January! ✨
Preview support for
JOINs for relation queries for PostgreSQL and CockroachDBWe’re excited to announce Preview support for
JOINs in Prisma Client when querying relations. Support forJOINs has been a long-standing feature request, and this release adds support for PostgreSQL and CockroachDB. The upcoming releases will expand support for other databases Prisma supports.To get started using
JOINs, enable the Preview feature in your Prisma schema:// schema.prisma generator client { provider = "prisma-client-js" previewFeatures = ["relationJoins"] }Run
prisma generateto regenerate Prisma Client and enable the Preview feature.Prisma Client will use a
JOINin your query to fetch relation data for a majority of the cases.Example queries
1-1 relation queries example
Prisma Client query
await prisma.user.findUnique({ where: { id: 1 }, include: { profile: true } })SQL
SELECT "t1"."id", "t1"."name", "User_profile"."__prisma_data__" AS "profile" FROM "public"."User" AS "t1" LEFT JOIN LATERAL ( SELECT COALESCE(JSON_AGG("__prisma_data__"), '[]') AS "__prisma_data__" FROM ( SELECT "t4"."__prisma_data__" FROM ( SELECT JSON_BUILD_OBJECT( 'id', "t3"."id", 'bio', "t3"."bio", 'userId', "t3"."userId" ) AS "__prisma_data__" FROM ( SELECT "t2".* FROM "public"."Profile" AS "t2" WHERE "t1"."id" = "t2"."userId" ) AS "t3" ) AS "t4" ) AS "t5" ) AS "User_profile" ON TRUE WHERE "t1"."id" = $1 LIMIT $21-m relation queries example
Prisma Client query
await prisma.user.findUnique({ where: { id: 1 }, include: { posts: true } })SQL
SELECT "t1"."id", "t1"."name", "User_posts"."__prisma_data__" AS "posts" FROM "public"."User" AS "t1" LEFT JOIN LATERAL ( SELECT COALESCE(JSON_AGG("__prisma_data__"), '[]') AS "__prisma_data__" FROM ( SELECT "t4"."__prisma_data__" FROM ( SELECT JSON_BUILD_OBJECT( 'id', "t3"."id", 'title', "t3"."title", 'content', "t3"."content", 'published', "t3"."published", 'authorId', "t3"."authorId" ) AS "__prisma_data__" FROM ( SELECT "t2".* FROM "public"."Post" AS "t2" WHERE "t1"."id" = "t2"."authorId" /* root select */ ) AS "t3" /* inner select */ ) AS "t4" /* middle select */ ) AS "t5" /* outer select */ ) AS "User_posts" ON TRUE WHERE "t1"."id" = $1 LIMIT $2m-n relation queries example
Prisma Client query
await prisma.post.findUnique({ where: { id: 1 }, include: { tags: true } })SQL
SELECT "t1"."id", "t1"."title", "t1"."content", "t1"."published", "t1"."authorId", "Post_tags_m2m"."__prisma_data__" AS "tags" FROM "public"."Post" AS "t1" LEFT JOIN LATERAL ( SELECT COALESCE(JSON_AGG("__prisma_data__"), '[]') AS "__prisma_data__" FROM ( SELECT "Post_tags"."__prisma_data__" FROM "public"."_PostToTag" AS "t2" LEFT JOIN LATERAL ( SELECT JSON_BUILD_OBJECT('id', "t4"."id", 'name', "t4"."name") AS "__prisma_data__", "t4"."id" FROM ( SELECT "t3".* FROM "public"."Tag" AS "t3" WHERE "t2"."B" = "t3"."id" /* root select */ ) AS "t4" ) AS "Post_tags" ON TRUE WHERE "t2"."A" = "t1"."id" ) AS "Post_tags_m2m_1" ) AS "Post_tags_m2m" ON TRUE WHERE "t1"."id" = $1 LIMIT $2Share your feedback and create a bug report if you encounter any issues.
Prisma’s
distinctoption now uses SQL queries (Preview)From this release, Prisma Client’s
distinctoption now uses the native SQLDISTINCT ONfor unordered queries with PostgreSQL and CockroachDB. The upcoming releases will expand support for the other databases that Prisma supports.Prisma Client already supports querying for distinct records. However, Prisma Client took care of the post-processing for distinct records in memory.
To get started, enable the Preview feature in your Prisma schema:
// schema.prisma generator client { provider = "prisma-client-js" previewFeatures = ["nativeDistinct"] }Regenerate your Prisma Client to get started using the Preview feature.
Given the following Prisma Client query:
await prisma.user.findMany({ distinct: ['role'], select: { role: true, }, })Before 5.7.0
Previously, Prisma Client handled the post-processing to select distinct records in-memory. Therefore, the following query was generated and executed against your database:
SELECT "public"."User"."id", "public"."User"."role"::text FROM "public"."User" WHERE 1 = 1 OFFSET $1
After 5.7.0
SELECT DISTINCT ON ("public"."User"."role") "public"."User"."id", "public"."User"."role"::text FROM "public"."User" WHERE 1 = 1 OFFSET $1Share your feedback and create a bug report if you encounter any issues.
Improved support for Netlify using Node.js v20
In this release, we improved Prisma support when deploying to Netlify on Node.js v20. Previously, the Prisma Client could not resolve the location of the Query Engine after deploying to Netlify when using Node.js v20. If you run into this issue, we recommend updating to Prisma v5.7.0.
We recommend giving this comment on GitHub a read if you are not yet able to upgrade Prisma, to learn how to get around the error.
Fixes and improvements
Prisma Client
Prisma
Prisma Migrate
Company news
We’re hiring!
If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you.
We're hiring for the following roles:
5.6.0
14 Nov 2023🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
🚀 Prisma Accelerate, our connection pool and global edge cache, is now Generally Available! Sign up to give it a try. 🚀
Highlights
Driver adapters improvements (Preview)
In version 5.4.0, we released
driverAdaptersinto Preview. ThedriverAdaptersfeature enables Prisma Client to access your database using JavaScript or Serverless database drivers.In this release, we fixed many bugs for the existing driver adapters. We appreciate all the community feedback that has helped us improve this feature!
PlanetScale serverless driver adapter improvements
This release also introduces a small breaking change to the
@prisma/adapter-planetscalepackage to improve its stability and performance. The serverless driver adapter will now use a connection pool instead of a single connection from PlanetScale’s serverless driver.In case you’re using the
@prisma/adapter-planetscale, update your Prisma Client instance with the following:-import { connect } from '@planetscale/database' +import { Client } from '@planetscale/database' import { PrismaPlanetScale } from '@prisma/adapter-planetscale' import { PrismaClient } from '@prisma/client' import { fetch as undiciFetch } from 'undici'; -const connection = connect({ url: connectionString, fetch: undiciFetch }) +const client = new Client({ url: connectionString, fetch: undiciFetch }) -const adapter = new PrismaPlanetScale(connection) +const adapter = new PrismaPlanetScale(client) const prisma = new PrismaClient({ adapter })If you run into the following error:
[TypeError]: PrismaPlanetScale must be initialized with an instance of Client., you can use the following snippet when defining your Prisma Client instance:import { createRequire } from "node:module"; import { PrismaPlanetScale } from "@prisma/adapter-planetscale"; import { fetch as undiciFetch } from 'undici'; const require = createRequire(import.meta.url); const { Client } = require("@planetscale/database"); const client = new Client({ url: process.env.DATABASE_URL , fetch: undiciFetch }) const adapter = new PrismaPlanetScale(client);Request for feedback
We encourage you to try out the driver adapters and share your feedback to help us move it to General Availability in either of the following GitHub discussions:
Refer to our docs to learn more about driver adapters.
New
prisma debugcommandThis release introduces a new command:
prisma debug. The command provides debugging information such as environment variables that Prisma Client, Prisma Migrate, Prisma CLI, and Prisma Studio use. The command is also useful when creating a bug report as the information complements the output of theprisma -vcommand.You can learn more about the command in our docs.
Read replicas extension improvements
We also released version 0.3.0 of the
@prisma/extension-read-replicaspackage that contains the following improvements:A new
$replica()method that explicitly enables you to use a replica for your query.For example, by default, the
queryRawandexecuteRawmethods are forwarded to the primary database, as they could try to write to the database. You can use the$replica()method with either of the*Rawmethods to explicitly execute your query against a replica instead of your primary database.Validation for when there’s an empty list of replicas.
Webpack bundling fixes
We want to thank you, our community members, for your contributions! 🙏
You can find additional information on the changes in the extension’s release. You can learn more about the extension in the announcement blog post.
Package provenance
npm has introduced provenance statements to improve supply-chain security and transparency of packages. This allows developers to verify where and how packages are built.
Starting with the 5.6.0 release, all npm packages for Prisma ORM will be published with provenance statements. If you maintain a Prisma Client extension or generator, we encourage you to enable provenance statements when publishing to npm.
Fixes and improvements
Prisma Migrate
Prisma Client
Prisma CLI
Company news
Prisma Accelerate is now Generally Available
We're excited to share that Prisma Accelerate is now Generally Available. Prisma Accelerate is a global database cache that's available in over 280 locations and provides scalable connection pooling for serverless and edge applications.
Learn more in the announcement blog post. Sign up and try out Prisma Accelerate here.
We’re hiring!
If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you.
We're hiring for an Engineering Manager: Prisma Data Platform.
5.5.2
25 Oct 2023Today, we are issuing the
5.5.2patch release.Fix in Prisma CLI
5.5.1
25 Oct 2023Today, we are issuing the
5.5.1patch release.Fix in Prisma Client
5.5.0
24 Oct 2023🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Serverless database drivers improvements and request for feedback (Preview)
In version 5.4.0, we released
driverAdaptersinto Preview. ThedriverAdapterfeature enables Prisma Client to access your database using other JavaScript or Serverless database drivers such as Neon, PlanetScale, and Turso.The driver adapters allow Prisma Client to connect to your database using protocols besides TCP, such as HTTP (PlanetScale and Turso) and WebSockets (Neon). You can learn more about the Preview feature from the announcement blog post.
In this release, we focused our efforts on fixing bugs and improving the stability of the Preview feature.
We encourage you to try it out and share your feedback to help us move it to General Availability in either of the following GitHub discussions:
New flags for the
prisma initcommandThis release introduces 3 new flags you can provide when initializing Prisma in your project using the
prisma initcommand:--generator-provider: Defines the default generator to use--preview-features: Specifies the default Preview features to use in your project--output: Specifies the default output location for the generated client
Fixes and improvements
Prisma CLI
Prisma Client
Invalid
….findMany()invocation: The columnj1.iddoes not exist in the current database.One-to-Many relationship does not join on the specified field
We're hiring!
If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you.
We're currently hiring for the following roles:
5.4.3
13 Oct 20235.4.2
9 Oct 2023Today, we are issuing the
5.4.2patch release.Fix in Prisma Client
5.4.1
6 Oct 2023Today, we are issuing the
5.4.1patch release.Fix in Prisma Client
Fix in
@prisma/adapter-planetscale5.4.0
4 Oct 2023Removed an unnecessary
INNER JOINused in relation filter queries (Big thank you to @KhooHaoYit for helping out)Use of
LEFT JOIN's for to-one relations. Previously, Prisma made use of sub-queries to fetch data.Removing all
SELECTqueries used to fetch data that would be used as input for theDELETEoperation. In some cases, this also improves index usage.
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Preview support for PlanetScale and Neon serverless database drivers
We’re excited to announce Preview support for the Neon and PlanetScale serverless database drivers. The PlanetScale and Neon serverless database drivers allow Prisma to connect to your database using protocols besides TCP — HTTP (PlanetScale) or WebSockets (Neon).
To get started with the serverless database drivers, first enable the
driverAdaptersPreview feature flag in your Prisma schema:// schema.prisma generator client { provider = "prisma-client-js" previewFeatures = ["driverAdapters"] }Next, to set up Prisma Client to use the serverless database drivers:
PlanetScale
Install the Prisma adapter for PlanetScale and PlanetScale serverless database driver, and undici:
npm install @prisma/adapter-planetscale @planetscale/database undici
Prisma ORM supports Node 16 and up. In Node 18 and up,
undiciis not needed.Ensure you update the host value in your connection string to
aws.connect.psdb.cloud. You can learn more about this here.DATABASE_URL='mysql://johndoe:strongpassword@aws.connect.psdb.cloud/clear_nightsky?sslaccept=strict'
Update your Prisma Client instance to use the PlanetScale database driver:
// Import required dependencies import { connect } from '@planetscale/database'; import { PrismaPlanetScale } from '@prisma/adapter-planetscale'; import { PrismaClient } from '@prisma/client'; import { fetch as undiciFetch } from 'undici'; // Initialize Prisma Client with the PlanetScale serverless database driver const connection = connect({ url: connectionString, fetch: undiciFetch }); const adapter = new PrismaPlanetScale(connection); const prisma = new PrismaClient({ adapter });PlanetScale Driver in 5.7.0 and later
In Prisma 5.7.0, usage of the PlanetScale driver adapter changed to the following:
// For Prisma 5.7.0 and later // Import required dependencies import { Client } from '@planetscale/database'; import { PrismaPlanetScale } from '@prisma/adapter-planetscale'; import { PrismaClient } from '@prisma/client'; // Initialize Prisma Client with the PlanetScale serverless database driver const client = new Client({ url: process.env.DATABASE_URL }); const adapter = new PrismaPlanetScale(client); const prisma = new PrismaClient({ adapter });Neon
Install the Prisma adapter for Neon, Neon serverless database driver and undici (WebSockets):
npm install @prisma/adapter-neon @neondatabase/serverless undici
Update your Prisma Client instance to use the Neon serverless database driver:
// Import required dependencies import { Pool, neonConfig } from '@neondatabase/serverless'; import { PrismaNeon } from '@prisma/adapter-neon'; import { PrismaClient } from '@prisma/client'; import { WebSocket } from 'undici' neonConfig.webSocketConstructor = WebSocket; // Initialize Prisma Client with the Neon serverless database driver const pool = new Pool({ connectionString: process.env.DATABASE_URL }); const adapter = new PrismaNeon(pool); const prisma = new PrismaClient({ adapter });Let us know your feedback about the Neon or Planetscale serverless database drivers in the linked GitHub discussions. Create a bug report if you run into any issues.
Early Access support for Turso
Turso is an edge-hosted, distributed database that's based on libSQL, an open-source and open-contribution fork of SQLite, enabling you to bring data closer to your application and minimize query latency.
Since support for Turso is in Early Access, there may be some rough edges which we’re still working on it to improve the API and overall support. Additionally, it is behind the
driverAdaptersPreview feature flag. Enable it to get started using Turso in your project:// schema.prisma generator client { provider = "prisma-client-js" previewFeatures = ["driverAdapters"] }Next, install the Prisma Client adapter for Turso and the
libSQLdatabase clientnpm install @prisma/adapter-libsql @libsql/client
Update your Prisma Client instance:
// Import required dependencies import { PrismaClient } from '@prisma/client' import { PrismaLibSQL } from '@prisma/adapter-libsql' import { createClient } from '@libsql/client' // Create a new instance of the libSQL database client const libsql = createClient({ // @ts-expect-error url: process.env.TURSO_DATABASE_URL, authToken: process.env.TURSO_AUTH_TOKEN }) // Create a Prisma "adapter" for libSQL const adapter = new PrismaLibSQL(libsql) // Pass the adapter option to the Prisma Client instance const prisma = new PrismaClient({ adapter })You can learn more on how to use Prisma together with Turso in the announcement blog post.
Try it out! Let us know what you think and create a bug report if you run into any issues.
Query performance improvements
In our continued efforts to make Prisma Client faster, we identified and improved the performance of different types of queries.
Relation filters improvements
We made the following improvements to relation filters:
Removed an unnecessary
INNER JOINused in relation filter queries (Big thank you to @KhooHaoYit for helping out)Use of
LEFT JOIN's for to-one relations. Previously, Prisma made use of sub-queries to fetch data.
Example Prisma Client query
prisma.comment.findMany({ where: { post: { author: { name: "John" } } } })Before 5.4.0
SELECT "Comment"."id" FROM "Comment" WHERE ("Comment"."id") IN ( SELECT "t0"."id" FROM "Comment" AS "t0" INNER JOIN "Post" AS "j0" ON ("j0"."id") = ("t0"."postId") WHERE ( ("j0"."id") IN ( SELECT "t1"."id" FROM "Post" AS "t1" INNER JOIN "User" AS "j1" ON ("j1"."id") = ("t1"."userId") WHERE ( "j1"."name" = $ 1 AND "t1"."id" IS NOT NULL ) ) AND "t0"."id" IS NOT NULL ) );After 5.4.0
SELECT "Comment"."id" FROM "Comment" LEFT JOIN "Post" AS "j1" ON ("j1"."id") = ("Comment"."postId") LEFT JOIN "User" AS "j2" ON ("j2"."id") = ("j1"."userId") WHERE ( "j2"."name" = $ 1 AND ("j2"."id" IS NOT NULL) AND ("j1"."id" IS NOT NULL) );If you’re interested in more details on the relation query filter improvements, you can take a look at this pull request.
Enum improvements on PostgreSQL and CockroachDB
Previously, when an enum value was used in a query, our Postgres driver would make additional queries to resolve the enum types that were used.
In this release, we’re making improvements by casting enums to
TEXTto avoid the additional roundtrips when resolving the types.This change should have the most impact if you’re using
pgBounceror if you’re running Prisma in a serverless environment, where our Postgres driver can’t cache enum types information.Prisma schema
model User { id Int @id @default(cuid()) role Role } enum Role { User Admin }Prisma Client query
await prisma.user.findMany({ where: { role: "Admin" } })Before 5.4.0
-- Internal driver query SELECT t.typname, t.typtype, t.typelem, r.rngsubtype, t.typbasetype, n.nspname, t.typrelid FROM pg_catalog.pg_type t LEFT OUTER JOIN pg_catalog.pg_range r ON r.rngtypid = t.oid INNER JOIN pg_catalog.pg_namespace n ON t.typnamespace = n.oid WHERE t.oid = $1; -- Internal driver query SELECT enumlabel FROM pg_catalog.pg_enum WHERE enumtypid = $1 ORDER BY enumsortorder; -- Prisma Client query SELECT id, role FROM "User" WHERE role = $1;
After 5.4.0
-- Prisma Client query SELECT id, role::text FROM "User" WHERE role = CAST($1::text AS "Role);
Bulk delete improvements
We optimized the
deleteManyoperation by:Removing all
SELECTqueries used to fetch data that would be used as input for theDELETEoperation. In some cases, this also improves index usage.Removing the transaction previously used as it’s now a single atomic operation.
Prisma Client query
await prisma.post.deleteMany({ where: { id: { gt: 1, lt: 10, } } })Before 5.4.0
BEGIN SELECT id FROM "Post" WHERE id > 1 AND id < 10; SELECT id FROM "Post" WHERE id > 1 AND id < 10 AND id IN (<...select ids>); DELETE FROM "Post" WHERE id IN (<...select ids>) AND id > 1 AND id < 10; COMMIT
After 5.4.0
DELETE FROM "Post" WHERE id > 1 AND id < 10;
Upsert improvements
We improved the
upsertoperation (non-native database upsert) by removing a redundantSELECTquery:Prisma Client query
await prisma.user.upsert({ where: { email: "john@doe.com" }, create: { email: "john@doe.com", firstName: "John" }, update: { firstName: "Johnny" }, })Before 5.4.0
SELECT `User`.`id` FROM `User` WHERE `User`.`email` = ?; SELECT `User`.`id` FROM `User` WHERE `User`.`email` = ?; UPDATE `prisma`.`User` SET `firstName` = ? WHERE `prisma`.`User`.`id` IN (?) AND `prisma`.`User`.`email` = ?; SELECT `User`.`id` FROM `User` WHERE `User`.`id` = ?;
After 5.4.0
SELECT `User`.`id` FROM `User` WHERE `User`.`email` = ?; UPDATE `prisma`.`User` SET `firstName` = ? WHERE `prisma`.`User`.`id` IN (?) AND `prisma`.`User`.`email` = ?; SELECT `User`.`id` FROM `User` WHERE `User`.`id` = ?;
Fixes and improvements
Prisma Client
Prisma can generate an overly complex and inefficient query in some cases
Enums loaded as part of transaction after
UPDATE, slowing down transaction.MongoDB
deleteManyseems to send 2 identical read queries first before triggering the actual deleteQuery validation messages reference color output even if colors are not enabled
Semver checks for yarn and typescript could potentially fail
Language tools (e.g. VS Code)
Prisma Engines
We're hiring!
If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you.
We're currently hiring for the following roles:
Feel free to read the job descriptions and apply using the links provided.
- 0.5.x
0.5.0
3 Oct 2023- 0.4.x
0.4.0
27 Sep 2023- 0.3.x