@prisma/nextjs-monorepo-workaround-plugin
7.10.1 · 15 Oct 2026Apache-2.0165.2k / weekRepositoryHomepagenpmAtom feed
100 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.2
9 Oct 2023Today, we are issuing the
5.4.2patch release.Fix in Prisma Client
5.4.1
4 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.
5.3.1
15 Sep 2023Today, we are issuing the
5.3.1patch release.Fix in Prisma Client
5.3.0
13 Sep 2023Validation for
undefinedvalues in arrays inJsonfields
We added runtime validation forundefinedvalues in arrays inJsonfields. Prisma Client will now return an error when an array contains anundefinedvalue. Therefore, we encourage you to add validation that either removes the value or transforms it tonullif you stumble on the runtime validation:// Query await prisma.user.findMany({ where: { // JSON field preferences: [undefined, '"theme": "dark"', null, ] } }) // Example error message on running the query Can not use `undefined` value within array. Use `null` or filter out `undefined` valuesPerformance improvements for models with many unique fields: This release improves Prisma Client’s memory consumption for models with many
@uniqueconstraints. This was a regression from version 4.10.1, where in some cases, if a model had many unique constraints, Prisma Client would use up a lot of available memory.Fixed the segmentation fault error that used to occur on ARM64 Linux binary targets
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
In this sprint, we’ve made bug fixes and overall improvements to Prisma Client. We’ve been working on a few projects that will be announced soon. Stay tuned for the upcoming releases for updates!
Improvements and bug fixes
We made the following changes:
Prisma Client improvements
Validation for
undefinedvalues in arrays inJsonfields
We added runtime validation forundefinedvalues in arrays inJsonfields. Prisma Client will now return an error when an array contains anundefinedvalue. Therefore, we encourage you to add validation that either removes the value or transforms it tonullif you stumble on the runtime validation:// Query await prisma.user.findMany({ where: { // JSON field preferences: [undefined, '"theme": "dark"', null, ] } }) // Example error message on running the query Can not use `undefined` value within array. Use `null` or filter out `undefined` valuesPerformance improvements for models with many unique fields: This release improves Prisma Client’s memory consumption for models with many
@uniqueconstraints. This was a regression from version 4.10.1, where in some cases, if a model had many unique constraints, Prisma Client would use up a lot of available memory.Fixed the segmentation fault error that used to occur on ARM64 Linux binary targets
Metrics Preview feature improvements:
We updated the counters and gauge properties
We fixed the bug that caused the
prisma_pool_connections_openmetric to have a negative value in some cases.
Prisma Migrate improvements
Fixed an introspection bug for MongoDB views. Previously, if a MongoDB database contained a view,
prisma db pullwould throw an error. We resolved this, and views are now ignored.Added the
PRISMA_SCHEMA_DISABLE_ADVISORY_LOCKenvironment variable that enables you to disable advisory locking.
VS Code extension improvements
Added support for rendering multi-line comments in tooltips when hovering on a block.
Improved the auto-completion for composite types in other blocks.
Added a Code Action that allows you to replace
SetDefaultwithNoActionwhen using MySQL and the default/foreignKeysrelation mode.
Fixes and improvements
Prisma Migrate
Percona-XtraDB-Cluster prohibits use of GET_LOCK with pxc_strict_mode = ENFORCING
Error in Connector on MongoDB executing listIndex: "system.views"
prisma migrate deploy:MariaDB doesn't yet support 'GET_LOCK in cluster (WSREP_ON=ON)'
Prisma Client
The prisma metrics
prisma_pool_connections_openhas a bug where it goes negativePrisma crashes with GraphQL queries of nested one-to-many relationship
Panic in Query Engine with SIGABRT signal (Debian Bookworm, engineType = binary)
Prisma 5 drops
undefinedfrom Arrays when using Json fields with PostgresSuspected memory leak in Lambda function after upgrading from 4.10.1
Error when generating - No unsupported field should reach that path
Language tools (e.g. VS Code)
5.2.0
22 Aug 2023Prisma Client will now automatically determine how it should connect to the database depending on the protocol in the connection string. If the connection string starts with
prisma://, Prisma Client will try to connect to your database using Prisma Accelerate or Prisma Data Proxy.Prisma Studio now works with Prisma Data Proxy and Prisma Accelerate.
We’ve introduced a new
--no-engineflag which will prevent a Query Engine file from being included in the generated Prisma Client. This flag will also help ensure the bundle size of your application remains small by excluding the Query Engine files from the generated Prisma Client.prisma generate --no-engine
The
--data-proxyand--accelerateflags have not been removed but are now aliases for the new--no-engineflag.We recommend using the
--no-engineflag when generating Prisma Client that uses either Accelerate or Data Proxy.
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Improved Prisma Client experience for Prisma Accelerate and Data Proxy
In this release, we’ve made the following improvements to Prisma Client when using Prisma Accelerate or Prisma Data Proxy:
Prisma Client will now automatically determine how it should connect to the database depending on the protocol in the connection string. If the connection string starts with
prisma://, Prisma Client will try to connect to your database using Prisma Accelerate or Prisma Data Proxy.Prisma Studio now works with Prisma Data Proxy and Prisma Accelerate.
We’ve introduced a new
--no-engineflag which will prevent a Query Engine file from being included in the generated Prisma Client. This flag will also help ensure the bundle size of your application remains small by excluding the Query Engine files from the generated Prisma Client.prisma generate --no-engine
The
--data-proxyand--accelerateflags have not been removed but are now aliases for the new--no-engineflag.We recommend using the
--no-engineflag when generating Prisma Client that uses either Accelerate or Data Proxy.
Simplified connection string override in Prisma Client
This release simplifies the API used when programmatically overriding the connection string by introducing the
datasourceUrlproperty in Prisma Client’s constructor. This means you do not have to use the datasource name defined in your Prisma schema.const prisma = new PrismaClient({ datasourceUrl: "postgresql://johndoe:randompassword@localhost:5432/mydb", })Query performance improvements
Continuing our work from 5.1.0 we made further performance improvements around the queries Prisma executes, targeting one-to-many relation fields and nested updates.
Use
LIMITin one-to-many relations on a single parentIn cases where there is a single parent with a one-to-many relation included (
findFirst,findUnique,findMany({ take: 1 })), we now utilizeLIMITat the database level to restrict the number of related items returned instead of retrieving all related items into memory and performing atakein memory.For situations where you have many related objects but only need a few, you should see a dramatic improvement in speed and memory usage.
Note: we are still working on bringing this improvement to other parts of Prisma Client in upcoming releases. If multiple parent records are returned, the previous behavior is used.
Further improvements for nested writes
Thanks to our introduction of using
RETURNINGin some cases in 5.1.0, we could now improve performance in nested writes by removing reload nodes. This will now result in one less query per relation traversed in a nested write. For more info, check out the pull request.Prisma Client query
await prisma.post.update({ where: { id: 1 }, data: { comment: { update: { data: { body: "Updated comment body" } } } }, select: { id: true, title: true, } })Before v5.2.0
SELECT "Post"."id", "Post"."title" FROM "Post" WHERE ("Post"."id" = $1 AND 1=1) LIMIT $2 OFFSET $3 SELECT "Post"."id", "Post"."userId" FROM "Post" WHERE "Post"."id" = $1 OFFSET $2 SELECT "User"."id" FROM "User" WHERE (1=1 AND "User"."id" IN ($1)) OFFSET $2 SELECT "User"."id" FROM "User" WHERE ("User"."id" = $1 AND 1=1) LIMIT $2 OFFSET $3 SELECT "User"."id", "User"."commentId" FROM "User" WHERE "User"."id" = $1 OFFSET $2 SELECT "Comment"."id" FROM "Comment" WHERE (1=1 AND "Comment"."id" IN ($1)) OFFSET $2 UPDATE "Comment" SET "body" = $1 WHERE ("Comment"."id" = $2 AND 1=1) RETURNING "Comment"."id" SELECT "Post"."id", "Post"."title" FROM "Post" WHERE "Post"."id" = $1 LIMIT $2 OFFSET $35.2.0 and later
SELECT "Post"."id", "Post"."title", "Post"."userId" FROM "Post" WHERE ("Post"."id" = $1 AND 1=1) LIMIT $2 OFFSET $3 SELECT "User"."id" FROM "User" WHERE (1=1 AND "User"."id" IN ($1)) OFFSET $2 SELECT "User"."id", "User"."commentId" FROM "User" WHERE ("User"."id" = $1 AND 1=1) LIMIT $2 OFFSET $3 SELECT "Comment"."id" FROM "Comment" WHERE (1=1 AND "Comment"."id" IN ($1)) OFFSET $2 UPDATE "Comment" SET "body" = $1 WHERE ("Comment"."id" = $2 AND 1=1) RETURNING "Comment"."id" SELECT "Post"."id", "Post"."title" FROM "Post" WHERE "Post"."id" = $1 LIMIT $2 OFFSET $3Fixes and improvements
Prisma Client
CFW: Avoid including Query Engine when data proxy is enabled
Postinstall hook always generates non Data Proxy Prisma Client
Cannot fetch data from service: include is not a functionError while using Next.js with Data Proxytakekey doesn't work correctly for nested query that returns one item with its nested childrenAdd documentation to "PrismaClient is unable to be run in the browser"
Change how Data Proxy Client deals with unsupported preview features
Custom Prisma Client output location breaks Prisma Data Proxy in NextJS
Browser bundle: Unhandled Runtime Error when upgrading to 5.1.0 from 5.0.0
Prisma Client:
disconnect: truedoes not appear to delete the foreign key in the returned dataBetter error message if
@prisma/client/edgecan not find environment variable5.1: Alias for old name for
<Model>CountOutputTypeDefaultArgsdoes not exist
Prisma Migrate
5.1.1
3 Aug 2023Today, we are issuing the
5.1.1patch release.Fixes in Prisma Client
5.1.0
1 Aug 2023Fix IPv6 not working for relational databases: #4051
Better error message in currently non-supported runtimes like Browser or Vercel Edge Runtime #20163
Today, we are excited to share the
5.1.0stable release 🎉🌟 Help us spread the word about Prisma by starring the repo ☝️ or tweeting about the release.
Highlights
After two big releases where we released Client extensions for production usage (
4.16.0) and made Prisma faster by default (5.0.0), we have focused on some smaller issues to make the experience with these new features even better.Community contributions
Our community has been on the roll! We appreciate everyone who helps us by opening a GitHub issue or proposing a fix via Pull Requests. In this release, we're excited to highlight multiple community contributions:
Fix IPv6 not working for relational databases: #4051
Middlewares: Add to
PrismaActiontype, missingfindUniqueOrThrowandfindFirstOrThrow#17471 by @mejiaej and missinggroupBy#19985Better error message in currently non-supported runtimes like Browser or Vercel Edge Runtime #20163
Remove error messages for valid NixOS setups #20138
Better performance: Fewer SQL queries on PostgreSQL & CockroachDB
In our continued and ongoing work to make Prisma faster, we identified some Prisma Client queries that led to multiple SQL statements being executed — although in specific databases, that was not necessary.
Hence we optimized our internal SQL generation for PostgreSQL and CockroachDB to generate more efficient SQL queries:
Simple
createqueryIn a simple
createquery,RETURNINGmakes the second query and the transaction statements obsolete:Prisma Client query
prisma.user.create({ data: { name: "Original name" } })Before v5.1.0
BEGIN INSERT INTO "User" ("name") VALUES ($1) RETURNING "User"."id" SELECT "User"."id", "User"."name" FROM "User" WHERE "User"."id" = $1; COMMIT5.1.0 and later
-- Sends 1 statement (instead of 2) and omits the transaction INSERT INTO "User" ("name") VALUES ($1) RETURNING "User"."id", "User"."name"Simple
updatequeryFor a simple
updatequery,RETURNINGmakes both additional queries and the transaction statements obsolete:Prisma Client query
prisma.user.update({ where: { id: 1 }, data: { name: "updated" } })Before v5.1.0
BEGIN SELECT id FROM "User" WHERE "User".id = 1; UPDATE "User" SET name = 'updated' WHERE "User".id = 1; SELECT id, name FROM "User" WHERE "User".id = 1; COMMIT
5.1.0 and later
-- Sends 1 statement (instead of 3) and omits the transaction UPDATE "User" SET name = 'updated' WHERE "User".id = 1 RETURNING "User".id, "User".name;
Simple
updatequery, return with relation valueOne
SELECTquery could easily be dropped in a simpleupdatequery that should return a relation value as well:Prisma Client query
prisma.user.update({ where: { id: 1 }, data: { name: "updated" }, includes: { posts: true } })Before v5.1.0
BEGIN SELECT id FROM "User" WHERE "User".id = 1; UPDATE "User" SET name = 'updated' WHERE "User".id = 1; SELECT id, name FROM "User" WHERE "User".id = 1; SELECT id, title FROM "Post" WHERE "Post"."userId" = 1; COMMIT
5.1.0 and later
-- Sends 3 statements (instead of 4) BEGIN UPDATE "User" SET name = 'updated' WHERE "User".id = 1 RETURNING "User".id; SELECT id, name FROM "User" WHERE "User".id = 1; SELECT id, title FROM "Post" WHERE "Post"."userId" = 1; COMMIT
Empty
updatequeryAn empty
updatequery can be optimized to skip the transaction and the second identical query by creating specific handling for this edge case in our code:Prisma Client query
prisma.user.update({ where: { id: 1 }, data: {}, })Before v5.1.0
BEGIN SELECT id, name FROM "User" WHERE "User".id = 1; SELECT id, name FROM "User" WHERE "User".id = 1; COMMIT
5.1.0 and later
-- Sends 1 statement (instead of 2) and omits the transaction SELECT id, name FROM "User" WHERE "User".id = 1;
Simple + relation
updatequery (but do not return relation value)An update of both the model and its relation, we could drop 2
SELECTqueries that we did before without ever using their return values:Prisma Client query
prisma.user.update({ where: { id: 1 }, data: { name: "updated", posts: { update: { where: { id: 1 }, data: { title: "updated" } } } } })Before v5.1.0
BEGIN SELECT id, name FROM "User" WHERE "User".id = 1; UPDATE "User" SET name = 'updated' WHERE "User".id = 1 RETURNING "User".id; SELECT "id", "postId" FROM "Post" WHERE "Post".id = 1; UPDATE "Post" SET title = 'updated' WHERE "Post"."userId" = 1 AND "Post".id = 1; SELECT id, name FROM "User" WHERE "User".id = 1; COMMIT
5.1.0 and later
-- Sends 3 statements (instead of 5) BEGIN UPDATE "User" SET name = 'updated' WHERE "User".id = 1 RETURNING "User".id, "User".name; SELECT "id", "postId" FROM "Post" WHERE "Post".id = 1; UPDATE "Post" SET title = 'updated' WHERE "Post"."userId" = 1 AND "Post".id = 1; COMMIT
In the next releases, we will continue optimizing Prisma Client queries to only run the minimal amount of SQL queries necessary.
If you notice any Prisma Client queries that are affected right now, please check the issues under our
performance/querieslabel. If you didn’t find one for what you’re seeing, please create a new issue. This will be super useful for us to understand all (edge) cases. Thank you!Prisma Studio now supports
directUrlOur CLI command
prisma studiothat opens Prisma Studio now also can use thedirectUrlproperty of thedatasourceblock so you can make it talk to a different database than defined inurl. This makes it easier to use Studio alongside the Prisma Data Proxy and Accelerate.Prisma Client: No more type clashes
We fixed (almost) all cases where using a specific term as a model name in your Prisma Schema would lead to a type clash due to Prisma’s generated typings. As a result of a type clash, it was not possible to use that model in your code (this was e.g. the case if you named a model
ModelorModelUpdate).We also deprecated the
<ModelName>Argstype as part of that fix. Going forward,<ModelName>DefaultArgsshould be used instead.Fixes and improvements
Prisma Client
Reduce the number of generated SQL statements for Updates/Inserts
Incorrect Include typings when having models called
XandXUpdateType name clash when
ModelandModelUpdateis defined in the schemaType error on query with select field (although query runs successfully)
Update operation includes multiple where statements for the same fields
Type conflict when naming a table {something} and a second table {something}Result
Type '"findUniqueOrThrow"' is not assignable to type 'PrismaAction'includenot working on models ending with...Updatewith unique compound indexPrisma Client: fixing type name clashes from generated client
Prisma Client: wrong type when using spread operator to set default values on query args
Using
Prisma.XyzFindManyArgsbreaksfindManytyping in v4.16.0+Prisma 5.0 Migration
findUniqueon@uniquecolumns that are enums<Tablename>UpsertArgsselect field does not match type fordb.<tablename>.upsert(item)TypeScript Error TS2322 when assigning JavaScript Date object to Prisma DateTime field
Types wrongly accept non-array parameter
byingroupByin 5.0.0Hovering over types (intellisense) shows confusing
GetResultInternal query batching fails when the table name is 'stores'
Client extensions result extensions should be applied after query extensions
Prisma Studio
Language tools (e.g. VS Code)
5.0.0
11 Jul 2023- Removed
ORoperator shortcuts - Removed
inandnotInoperator shortcuts - Removed
PostgreSQL JSON
pathfield shortcut
We’re excited to share the
5.0.0release today 🎉Prisma
5.0.0contains a lot of changes that improve Prisma’s performance, especially in serverless environments. If you want to learn more about the performance improvements, we wrote a blog post that sums up all the changes we made: Prisma 5: Faster by Default.As this is a major release, it includes a few breaking changes that might affect a small group of our users. Before upgrading, we recommend that you check out our upgrade guide to understand the impact on your application.
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Here’s a summary of the changes:
Preview features moved to General Availability
jsonProtocol: improves communication between Prisma Client and the query engine, makes Prisma faster by default.fieldReference: adds support for comparing columns of the same table.extendedWhereUnique: adds support for non-unique columns insidewhereclauses for queries that operate on unique records.
General improvements and breaking changes
Dependency version changes
Minimum Node.js version change to 16.13.0
Minimum TypeScript version change to 4.7
Minimum PostgreSQL version change to 9.6
Prisma Client embedded SQLite version upgrade to 3.41.2
Main Changes
Removal of
rejectOnNotFoundpropertyRemoval of some array shortcuts
cockroachdbprovider is now required when connecting to a CockroachDB databaseRemoved
runtime/index.jsfrom the generated Prisma Client
Other Changes
Removal of deprecated flags in the Prisma CLI
Removal of the
beforeExithook from the library engineRemoval of deprecated
prisma2executableRemoval of deprecated
experimentalFeaturesgenerator property in the Prisma schemaRenamed
migration-enginetoschema-engine
A JSON-based protocol that improves Prisma’s performance
We’re thrilled to announce that the
jsonProtocolPreview feature is now Generally Available. You can now remove the Preview feature flag from your schema after upgrading. We made the JSON-based wire protocol the default protocol used for communication between Prisma Client and the query engine.We introduced this feature in version 4.11.0 to improve Prisma’s performance. Previously, Prisma used a GraphQL-like protocol to communicate between Prisma Client and the query engine. Applications with larger schemas had higher CPU and memory consumption compared to smaller schemas which created a performance bottleneck.
The JSON-based wire protocol improves efficiency when Prisma Client is communicating with the query engine.
Removal of array shortcuts
We took the opportunity to remove some array shortcuts to make our typings more consistent and logical. These shortcuts were a way to add a single element as a value to an array-based operator instead of wrapping a single element in an array. We will now require array values for the following:
- Removed
ORoperator shortcuts - Removed
inandnotInoperator shortcuts - Removed
PostgreSQL JSON
pathfield shortcut - Removed
Scalar list shortcuts
- Removed
MongoDB Composite types list shortcuts
Here’s an example query using the
ORoperator shortcut for a single element;await prisma.user.findMany({ where: { - OR: { email: 'alice@prisma.io' } + OR: [{ email: 'alice@prisma.io' }] } })We recommend taking a look at the upgrade guide to learn how you can update your queries to work in Prisma 5.
Support for comparing multiple columns
We’re excited to announce that the
fieldReferencePreview feature is now stable and Generally Available. This means you can use this feature without the Preview feature flag in your Prisma schema.We first introduced this feature in 4.5.0 to add the ability to compare columns on the same table. For example, the following query returns records where the
quantityvalue is less than thewarnQuantityof a product:await prisma.product.findMany({ where: { quantity: { lte: prisma.product.fields.warnQuantity } }, })To learn more about this feature, refer to our documentation.
Support for filtering non-unique columns in queries for a unique record
We’re excited to announce the
extendedWhereUniquePreview feature is now Generally Available. This means you can use the feature without the Preview feature flag in the Prisma schema.We first introduced this feature in version 4.5.0 to add support for non-unique columns inside
whereclauses for queries that operate on unique records, such asfindUnique,update, anddelete, which was previously not possible.For example, consider the following model:
model Article { id Int @id @default(autoincrement()) content String version Int }You can filter on non-unique columns such as the
versionfield as follows:await prisma.article.findUnique({ where: { id: 5, version: 1 // filter on the `version` field was not available before Prisma 4.5.0 }, });To learn more about this feature, refer to our documentation.
Minimum Node.js version change to 16.13.0
The minimum version of Node.js Prisma supports is
16.13.0. If you're using an earlier version of Node.js, you will need to upgrade your Node.js version.Refer to our system requirements for the minimum versions Prisma requires.
Minimum TypeScript version change to 4.7
The minimum version of TypeScript Prisma supports is 4.7. If your project is using an earlier version of TypeScript, you will need to upgrade your TypeScript version.
Refer to our system requirements for the minimum versions Prisma requires.
Minimum PostgreSQL version change to 9.6
The minimum version of PostgreSQL Prisma supports is version 9.6. If you’re either using 9.4 or 9.5, you will need to update your PostgreSQL version to at least 9.6.
Refer to our system requirements for the minimum database versions Prisma requires.
Prisma Client embedded SQLite version upgrade
We upgraded the embedded version of SQLite from 3.35.4 to 3.41.2. We do not anticipate any breaking changes or changes needed in projects using SQLite. However, if you’re using SQLite, especially with raw queries that might go beyond Prisma's functionality, make sure to check the SQLite changelog.
Removal of
rejectOnNotFoundpropertyIn version 5.0.0, we removed the
rejectOnNotFoundparameter from Prisma Client that was deprecated in version 4.0.0. We removed this feature to provide better type-safety using thefindUniqueOrThrowandfindFirstOrThrowmethods as well have a consistent API.If you are using the
rejectOnNotFoundparameter we recommend either:- Removed
Replacing your queries with the
findFirstOrThroworfindUniqueOrThrowmethods if enabled at a query-level - Removed
Using a Prisma Client extension to overload the
findFirstOrThrowandfindUniqueOrThrowmodel methods with your custom error handling if enabled at the client-level
We recommend taking a look at the upgrade guide for more information on how to adapt your application if you’re using
rejectOnNotFound.cockroachdbprovider is now required when connecting to a CockroachDB databasePrior to adding explicit support for CockroachDB with the
cockroachdbprovider in 3.9.0, it was possible to use the PostgreSQL provider when working with CockroachDB databases.We’re now making it mandatory to use the CockroachDB connector when working with CockroachDB databases. CockroachDB and PostgreSQL have a few differences such as the available native types which impact the generated migrations.
If you were using the PostgreSQL connector to work with CockroachDB, take a look at the upgrade guide to learn how you can update your connector.
Removal of the generated
runtime/index.jsfile from Prisma ClientWith Prisma 5, we removed the
runtime/index.jsfile from Prisma Client. If you were using APIs fromruntime/index.js, such asDecimal,PrismaClientKnownRequestError,NotFoundError,PrismaClientUnknownRequestError, we recommend updating your imports:- import { Decimal } from '@prisma/client/runtime' + import { Prisma } from '@prisma/client' // Usage update of Prisma Client's utilities - Decimal + Prisma.DecimalWe recommend taking a look at the upgrade guide to learn how you can migrate to Prisma 5
Removal of the
beforeExithook from thelibraryquery engineWe removed the
beforeExithook from the defaultlibraryQuery Engine. We recommend using the built-in Node.js exit events.-prisma.$on('beforeExit', () => { /* your code */ }) // Replacements process.on('beforeExit', () => { /* your code */ }) process.on('exit', exitHandler) process.on('SIGINT', exitHandler) process.on('SIGTERM', exitHandler) process.on('SIGUSR2', exitHandler)We recommend taking a look at the upgrade guide to learn how you can migrate to Prisma 5.
Removal of deprecated
prisma2executableWhen we released Prisma 2, the
prisma2executable was used to differentiate it from Prisma 1. In a later release, theprisma2CLI took over theprismaexecutable name.The
prisma2executable has been deprecated for a while and will now be removed. If you’re usingprisma2in your scripts, replace it withprisma.Removal of deprecated flags in the Prisma CLI
We removed the following deprecated flags in the Prisma CLI:
- Removed
--preview-feature: used in theprisma db execute,prisma db seed, andprisma migrate diffcommands - Removed
--experimentaland--early-access-feature: used in theprisma migratecommands such asprisma migrate dev - Removed
--force: forprisma db push. The--forceflag was replaced by--accept-data-lossin version 2.17.0 - Removed
--experimental-reintrospectionand--clean: forprisma db pull
In the event you’re using one of these flags, we recommend removing the flags.
Removal of deprecated
experimentalFeaturesgenerator propertyIn this release, we removed the
experimentalFeaturesproperty that used to be in the generator property in the Prisma schema but has been renamed topreviewFeaturesfor a long time now. If you’re still using this property, you can either manually rename it topreviewFeaturesor use the VS Code action to rename it if you’re using the latest version of the Prisma VS Code extension.Renamed
migration-enginetoschema-engineIn this release, we renamed the
migration-engine, responsible for running introspection and migration commands, toschema-engine. For the majority of our users, no changes will be required. However, if you explicitly include or exclude the engine files you will need to update your code references. Refer to the upgrade guide for more information.Fixes and improvements
Prisma Client
Getting a string '(array)' in the generator config instead of the expected value when array is used
Client extensions incorrect typings when defined both specific model and all models methods
<Model>RelationFilterInputdoes not take nullability into accountFull text search query with
ORbroke after opting in tojsonProtocolfeature.Remove outdated preview feature aliases (transactionApi, aggregateApi)
Only upload engines files to
binaries.prisma.sh/all_commits/Prisma Client: remove "beforeExit" hook from LibraryEngine/DataProxyEngine
Prisma Client: remove legacy
photonResolverandprovider=photonjshandlingRemove backward compatibility for Prisma Client < 2.20 and Prisma CLI >= 2.20
Can't specify $queryRawUnsafe return type after extending prisma client
4.16.x cannot wrap
$extendin factory function whencompilerOptions.compositeistrue4.16: (MongoDB) Generated types for list composites are incorrect
Prisma Client Extensions: $allModels: { $allOperations } sets
querytype toneverPrisma Schema Type inside a Type not generating a right Payload
Prisma Client fluent API does not work with extends anymore on 4.16.1
Prisma not generating correct payload for types in models for MongoDB for 4.16.1
Prisma requires to install bun when generating client library
Result types are incorrectly inferred when
undefinedexplicitly passed toselect/includeMigrating to release: 4.16.2 throws typescript error: "TS1005: '?' expected".
Prisma Migrate
Make connecting to a cockroachdb database with
provider = "postgresql"an errorRemove the deprecated
experimentalFeaturesgenerator propertyPrisma CLI: remove deprecated flags, arguments and "old migrate" logic
Language tools (e.g. VS Code)
Join us for another "What's new in Prisma" live stream
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" live stream.
The stream takes place on YouTube on Thursday, July 13 at 5 pm Berlin | 8 am San Francisco.
- 4.x
4.16.2
30 Jun 2023Today, we are issuing the
4.16.2patch release.Fixes in Prisma Client
4.16: (MongoDB) Generated types for list composites are incorrect
Prisma Client fluent API does not work with extends anymore on 4.16.1
Prisma Client Extensions:
$allModels: { $allOperations }sets query type toneverResult types are incorrectly inferred when
undefinedexplicitly passed toselect/include
4.16.1
22 Jun 2023Today, we are issuing the
4.16.1patch release.Fixes in Prisma Client
4.16.0
20 Jun 2023Prisma Client extensions
Ordering by nulls first and last
Count by filtered relation
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
This release promotes the following Preview features to General Availability:
Prisma Client extensions
Ordering by nulls first and last
Count by filtered relation
Prisma Client extensions are Generally Available
Today, we’re very excited to announce that Prisma Client extensions are Generally Available and production-ready! This means you can use the feature without the
clientExtensionsPreview feature flag.🚀Prisma Client extensions are a powerful new feature for adding functionality on top of your Prisma Client in a type-safe manner. With this feature, you can create simple, but flexible solutions.
Prisma Client extensions have 4 different types of components that can be included in an extension:
Result extensions components: add custom fields and methods to query result objects, for example, virtual/computed fields.
Model extensions components: enable you to add new methods to your models alongside existing model methods such as
findMany.Query extensions components: let you hook into the lifecycle of a query and perform side effects, modify query arguments, or modify the results in a type-safe way. These are an alternative to middleware that provide complete type safety and can be applied in an ad-hoc manner to different extensions.
Client extensions components: allow you to add new top-level methods to Prisma Client. You can use this to extend Prisma Client with functionality that isn’t tied to specific models.
const prisma = new PrismaClient().$extends({ name: "extension-name", result: { /* ... */ }, model: { /* ... */ }, query: { /* ... */ }, client: { /* ... */ }, });You can also create and publish extensions for others to use. Learn more about how to share extensions in our documentation.
More features and changes made to Client Extensions
We also made the following improvements to Prisma Client extensions in preparation for General Availability:
Added a top-level
$allOperationsmethod forquerycomponent that captures all model operations as well as top-level raw queries. Refer to our documentation for more information.const prisma = new PrismaClient().$extends({ query: { $allOperations({ args, query, operation, model }) { /* your extension's logic here */ } } })Prisma.validatorcan now also be used for extended types:const prisma = new PrismaClient().$extends({/* ... */}) const data = Prisma.validator(prisma, 'user', 'findFirst', 'select')({ id: true, })querycallbacks for$queryRawand$executeRawwill always receiveSqlinstance asargs. This instance can be used to compose a new query usingPrisma.sql:const prisma = new PrismaClient().$extends({ query: { $queryRaw({ args, query }) { return query(Prisma.sql`START TRANSACTION; ${args}; COMMIT;`) } } })$oncannot be called after extending Prisma Client. Therefore, if you want to use event handlers together with extensions, we recommend using the$onmethod before$extends.const prisma = new PrismaClient() .$on(/* ... */) .$extends({/* ... */})We updated the import path for utilities used for authoring extension to
@prisma/client/extensionrather than@prisma/client+ import { Prisma } from "@prisma/client/extension" - import { Prisma } from "@prisma/client"
Deprecating Middleware
We also took this opportunity to deprecate Prisma Client’s middleware. We recommend using to using Prisma Client
queryextension components which can be used to achieve the same functionality and with better type safety.🚧 Middleware will still be available in Prisma Client’s API. However, we recommend using Prisma Client extensions over middleware.
Ordering by nulls first and last is now Generally Available
Starting with this release, we’re excited to announce that
orderByNullsis now Generally Available! This means you can use the feature without theorderByNullsPreview feature flag.🌟We introduced this feature in 4.1.0 to enable you to sort records with null fields to either appear at the beginning or end of the result.
The following example query sorts posts by
updatedAt, with records having a null value at the end of the list:await prisma.post.findMany({ orderBy: { updatedAt: { sort: 'asc', nulls: 'last' }, }, })To learn more about this feature, refer to our documentation.
We’re excited to see what you will build! Feel free to share with us what you build on Twitter, Slack, or Discord.
Count by filtered relation is now Generally Available
This release moves the
filteredRelationCountPreview feature to General Availability! This means you can use the feature without thefilteredRelationCountPreview feature flag.We first introduced this feature in 4.3.0 to add the ability to count by filtered relations.
The following query, for example, counts all posts with the title “Hello!”:
await prisma.user.findMany({ select: { _count: { select: { posts: { where: { title: 'Hello!' } }, }, }, }, })To learn more about this feature, refer to our documentation.
Introspection warnings for expression indexes
In the last two releases, 4.13.0 and 4.14.0, we added 9 introspection warnings. These warnings surface features in use in your database that cannot currently be represented in the Prisma schema.
In this release, we’re adding one more introspection warning to the list: expression indexes.
On database introspection, the Prisma CLI will surface the feature with a warning, and a comment in your Prisma schema for sections for each feature in use. The warnings will also contain instructions for workarounds on how to use the feature.
Fixes and improvements
Prisma Client
Misleading error message of
prisma generatewhen running it directly after installingprismaPrisma.validator: with clientExtensions enabled, Typescript can no longer compute types
Client extensions in interactive transactions are bound to the base client
$runCommandRawis not passing the expected data to middleware or client extensionSequential transactions run out of order when using client extensions and middleware
Client Extension: Make
.prismaVersion.clientavailable on "@prisma/client/scripts/default-index"Cannot create record with Prisma.DbNull when clientExtensions enabled
Extended client raw queries fail when using the Prisma.sql helper
PCE: Query extensions of
$queryRawUnsafealso triggers$allModels.$allOperationsPCE:
$onapplied to an extended client is also bound to the parent client$queryRaw*is broken in interactive transactions together withclientExtensionsin4.16.0-dev.17Deploying to an offline environment fails because it tries to download a Prisma engine checksum file
jsonProtocol: Wrong error message shown for validation error for checked/unchecked types
Prisma Migrate
Language tools (e.g. VS Code)
Prisma Studio
Join us for another "What's new in Prisma" live stream
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" live stream.
The stream takes place on YouTube on Thursday, June 22 at 5 pm Berlin | 8 am San Francisco.
4.15.0
30 May 2023Seeding different data in different environments
Partially seeding data in some tables
The downloaded Query Engine doesn’t match the runtime/ target platform your application is running on.
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
For this release, we focused on fixing bugs and making smaller quality-of-life improvements.
Support for custom arguments for
prisma db seedThis release adds support for defining and passing arbitrary arguments to
prisma db seed. This creates the opportunity for you to define your own arguments in your seed file that you could pass to theprisma db seedcommand. A few example use-cases include, but are not limited to:Seeding different data in different environments
Partially seeding data in some tables
Here is an example
seed.tsfile that defines custom arguments for seeding different data in different environments:// prisma/seed.ts import { parseArgs } from "node:util"; const options = { environment: { type: 'string', }, } async function main() { const { values: { environment } } = parseArgs({ options }) switch (environment) { case "development": /** do something for development */ break; case "test": /** do something for test environment */ break; default: break; } } main()You can then provide the
environmentargument when executing the seed script as follows:npx prisma db seed -- --environment development
Let us know what you think, share example usage of this feature, and create a bug report if you run into any issues.
Improved error messages when Query Engine file is not found
This release improves the error messages returned by Prisma Client when the Query Engine file is not found. A few reasons the Query Engine file might be missing from your application bundle include when:
The downloaded Query Engine doesn’t match the runtime/ target platform your application is running on.
The Query Engine is not copied to your final application bundle during the build step.
We hope these error messages are helpful while debugging your application.
Prisma VS Code extension improvements
In this release, we made a few improvements to our VS Code extension:
Updated the file system watcher that is responsible for restarting the TypeScript server when
prisma generateis run to ensure the types are in syncNote:
This new approach is currently only available on Windows and Linux. We plan on adding support for the new file system watcher on macOS soon.
This requires both Prisma CLI & VS code extension version
4.15.0or higher
Added Quick Fixes action for unique identifiers for MongoDB to add the
@map("_id")attribute function when it’s missing on an identifier fieldSupport for renaming symbols for composite types and views
Fixes and improvements
Prisma Client
prisma generateis blocked byquery-engine-rhel-openssl-1.0.xopening in Notepad on WindowsIssue with Yarn Workspace Monorepo: Query engine binary for current platform could not be found.
Deploying to Cloudflare Workers | "PrismaClient is unable to be run in the browser"
No client schema when using PrismaClient during cached (standard) Netlify build
Module "@prisma/client" has no exported member "PrismaClient"
prisma/client crashes when used with older versions of react-refresh
Unable to run prisma cli in pnpm monorepo from workspace install
Prisma seems to be looking in the wrong location for rhel-openssl-1.0.x
Query engine library for current platform could not be found.
GraphQL protocol encoder incorrectly turns empty array into empty object.
GraphQL protocol: Invalid
Datevalues silently turn intonulls@prisma/client/edge + Cloudflare Worker / wrangler = Could not resolve "os"
Client is bricked from connecting to DB if first attempt fails.
JSON protocol: incorrect recursive composites detection through multiple nesting levels
Prisma Migrate
Language tools (e.g. VS Code)
Join us for another "What's new in Prisma" live stream
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" live stream.
The stream takes place on YouTube on Thursday, June 1 at 5 pm Berlin | 8 am San Francisco.
4.14.1
17 May 2023Today, we are issuing the
4.14.1patch release.Fix in Prisma Client
4.14.0
9 May 2023🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Request for feedback for Preview features
We would appreciate your feedback on a handful of Preview features to help us move them to General Availability soon. The Preview features include:
You can test them by enabling the Preview feature in your Prisma schema and giving them a try already in your Prisma schema, e.g., PostgreSQL extensions, or regenerating Prisma Client and trying them in your queries.
Highlights
Improved Prisma Client startup performance
For the last couple of months, we've been working hard to improve the performance of Prisma Client. We also published a blog post on how How We Sped Up Serverless Cold Starts with Prisma by 9x, which we recommend you give it a read.
This release continues with the same theme by making the size of the generated Prisma Client smaller. We have roughly halved the size of Prisma Client's dependencies.
More Introspection warnings for unsupported features
In 4.13.0, we introduced the first 6 introspection warnings that surface the existence of these features in your database and link to our documentation on how to manually work around the Prisma Schema with unsupported database features.
In this release, we added 3 more introspection warnings for the following features:
Check Constraints (MySQL + PostgreSQL)
On introspecting a database using any of these features, you will get a warning from the Prisma CLI and a comment in your Prisma schema where the feature is being used. The warning will also contain a link to instructions on how to manually use the feature.
Fixes and improvements
Prisma Client
- Deprecated
DeprecationWarning: Implicit coercion to integer for exit code is deprecated
jsonProtocol:
inargument of filter types does not accept scalarsCan't find the schema when the project path contains the same name as the generated client folder
Prisma Migrate
Introspection warnings: move rendering from
DbPull.tsto the engineviews: don't create local
viewsfolder on introspection if no views are found
Language tools (e.g. VS Code)
Join us for another "What's new in Prisma" live stream
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" live stream.
The stream takes place on YouTube on Thursday, May 11 at 5 pm Berlin | 8 am San Francisco.
4.13.0
18 Apr 2023🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Introspection warnings for unsupported features
The Prisma Schema Language (PSL) currently doesn't support all database features and functionality of our target databases. The PSL is an abstraction over SQL and will keep evolving to address gaps in our database feature matrix.
Before this release,
prisma db pulldid not pick up the unsupported features in a database. It was easy to lose them when runningprisma migrate devbased on an existing Prisma schema if not included in a migration file using custom migrations.To avoid this, we added introspection warnings that surface the existence of these features in your database and link to our documentation on how to manually work around the Prisma Schema with unsupported database features.
In this release, we added introspection warnings for the following features:
Prisma CLI will output warnings on introspection (
prisma db pull) and add comments to your Prisma schema. In the coming releases, we will expand this to many more features labeled withtopic: database-functionalityon GitHub.Improved support for Netlify and Vercel build process
Netlify and Vercel cache project dependencies during the build process and reuse that cache until dependencies change. While this helps speed up the build process, any
postinstallscripts of these dependencies will not be executed.Prisma uses a
postinstallscript in its package to automatically trigger the customized generation of Prisma Client for your Prisma Schema. When a dependency cache is used, that generation process is not triggered, and an outdated Prisma Client may be used in your application.When you update your Prisma Schema but not your dependencies, Prisma Client will not be generated for the new schema. For example, columns you added recently to one of your models will not be present in the Prisma Client API - causing errors.
This problem can be avoided by:
Adding a custom
postinstallscript in yourpackage.jsonfileManually adding a
prisma generatestep to the “Build” scripts of Vercel and Netlify.
We now added detection of this scenario and will prevent a build without an additional
prisma generate. This will ensure you're aware of the problem early and get guidance on how to fix this problem. You can read more on how to do this in our docs — Vercel caching troubleshooting, Netlify caching troubleshooting.Better support for pnpm as a package manager
Before this release, Prisma only used npm scripts which would lead to undesirable behavior for a project using a different package manager such as pnpm and yarn. This release improves the detection of the package managers in your project by using
ni. If you're still running into this problem, let us know by creating a GitHub issue.Segmentation fault and TLS connection error fix
In this release, we've fixed a TLS connection error segmentation fault. This mostly affected users running on Node.js 17 or later with OpenSSL 1.1 when using TLS to connect to their database.
JSON protocol Preview feature feedback
We have fixed multiple bugs for the
jsonProtocolPreview feature and are close to making it Generally Available. We are still looking for feedback about its usage to ensure it is ready and works as expected for everyone.We would appreciate it if you would try it out, help us polish the feature, and move it to General Availability. Testing it requires little effort. You can test it using the following steps:
Enabling the
jsonProtocolPreview feature in your Prisma schemaRe-generating Prisma Client
Running your application or tests to make sure everything works
We encourage you to leave your feedback in this GitHub issue or create a bug report if your run into any issues.
Fixes and improvements
Prisma Client
pnpm: Can not
prisma generatewhen@prisma/clientis not installed in projectSegmentation fault crash when using prisma client when using PostgreSQL
Docker with
pnpm installhangs on@prisma/clientpostinstallAutomatic installation of missing dependencies isn't compatible with pnpm
Using Prisma with pnpm results in inability to call database related commands
99056 segmentation fault (core dumped) node --require esbuild-register prisma/seed.ts
JSON protocol: sibling composites of the same type are rejected
Prisma Migrate
Language tools (e.g. VS Code)
Join us for another "What's new in Prisma" live stream
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" live stream.
The stream takes place on YouTube on Thursday, April 20 at 5 pm Berlin | 8 am San Francisco.
4.12.0
28 Mar 2023🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Introspection of Views SQL improvements (Preview)
The
viewsPreview feature significantly improved this release:prisma db pullnow reads the SQL query used to define a view and stores it in a.sqlfile in aviewsfolder next to your Prisma schema.Note: These
.sqlfiles are not yet used for creating or updating views during migrations yet. For now, we are only looking for feedback. Let us know if the introspected SQL files match the views picked up in your database and if the correct files were created in your filesystem.We encourage you to leave feedback in this GitHub issue.
Improvements to JSON protocol (Early Preview)
In 4.11.0, we announced the
jsonProtocolPreview feature which had some rough edges. This release improves the Preview feature by providing polished and helpful error messages from Prisma Client when something goes wrong. Here is an example error message:!(user-images.githubusercontent.com/33921841/2281…)
We would appreciate it if you would try it out to help us polish the feature and move it to General Availability. Testing it requires little effort. Please also leave any feedback in this issue, or open a new one if you want to report a bug.
Prisma Client startup performance
In this release, we've improved the startup performance of Prisma Client. We're keen on improving the performance of Prisma Client. If you experience any problems with the startup performance, be sure to report them so that we can look into them.
Open Telemetry tracing and logging for Prisma Client for Data Proxy
This release adds support for Open Telemetry tracing (via the
tracingPreview feature) and logging to Prisma Client for Data Proxy.Fixes and improvements
Prisma Migrate
Certain types of schema changes don't work with CockroachDB v22.2
Completions: provided by engines break right at the start of a newline
Unable to reset CockroachDB for table with foreign key relationship on v22.2.
MySQL multi-value index removes the primary key on introspection
Prisma Client
Missing
PrismaPromiseexport after update from 4.9.0 to 4.11.0Prisma 4.11 breaks multilevel relation with compound primary keys (typings)
4.11.0:
Unique constraint failed on the fieldson query that worked in 4.10.1jsonProtocolField/Enum is not included in the result of the findFirst/findMany functionToo many records are returned in 4.11.0 when using nested include and @unique field is null
Language tools (e.g. VS Code)
Join us for another "What's new in Prisma" live stream
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" live stream.
The stream takes place on YouTube on Thursday, March 30 at 5 pm Berlin | 8 am San Francisco.
4.11.0
28 Feb 2023Does using this preview feature introduce any regressions or problems in your application?
If not, how does it influence the performance of your application? Can you share before and after measurements?
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
JSON protocol Early Preview
This release introduces an early Preview feature: JSON protocol.
During performance investigations and optimizations, we noticed that the existing implementation added a CPU and memory overhead that was especially noticeable for larger Prisma schemas. Therefore, we found an alternative way to express our queries without needing that overhead: JSON.
To try out the new protocol, enable the
jsonProtocolPreview feature in your Prisma schema:generator client { provider = "prisma-client-js" previewFeatures = ["jsonProtocol"] }Regenerate Prisma Client to use the new JSON protocol.
For environments or situations where it is not viable to enable the Preview feature flag to your Prisma schema file, we also added an environment variable that you can use to force the use of the JSON Protocol Preview feature:
PRISMA_ENGINE_PROTOCOL=json.Note: This is an early Preview feature with a significant limitation: Invalid input to Prisma Client will throw unpolished, internal errors that are less descriptive and user-friendly than our usual ones. We intend to improve these future releases. Using it with Data Proxy and Prisma Data Platform currently also leads to errors.
We expect using
jsonProtocolto improve Prisma Client's startup performance significantly. This will likely have a more significant impact on applications with larger Prisma schemas.We would appreciate your feedback on this feature on the following particularly:
Does using this preview feature introduce any regressions or problems in your application?
If not, how does it influence the performance of your application? Can you share before and after measurements?
For feedback, please comment on the GitHub feedback issue.
Introspection support for MySQL, SQL Server, and CockroachDB views
You can now run
prisma db pullagainst your database to populate your Prisma schema with your views in MySQL, SQL Server, and CockroachDB.To learn more, refer to our documentation on views introspection. Try it out and let us know your thoughts in this GitHub issue.
Prisma Client extensions improvements: raw query operations
This release adds support for extending top-level raw query operations.
const prisma = new PrismaClient().$extends({ query: { // relational databases $queryRaw({ args, query, operation }) { // handle $queryRaw operation return query(args) }, $executeRaw({ args, query, operation }) { // handle $executeRaw operation return query(args) }, $queryRawUnsafe({ args, query, operation }) { // handle $queryRawUnsafe operation return query(args) }, $executeRawUnsafe({ args, query, operation }) { // handle $executeRawUnsafe operation return query(args) }, // MongoDB $runCommandRaw({ args, query, operation }) { // handle $runCommandRaw operation return query(args) }, }, })Webpack plugin for Next.js apps using Prisma in monorepo setups
If you've been using Prisma Client in a Next.js app in a monorepo setup, you might have seen this infamous error message:
Error: ENOENT: no such file or directory, open schema.prisma
We finally pinpointed the problem's source to the Next.js bundling step and opened an issue in the Next.js repository for Vercel to investigate and hopefully fix it.
In the meantime, we've created a workaround via a webpack plugin that makes sure your Prisma schema is copied to the correct location:
@prisma/nextjs-monorepo-workaround-plugin.To use the plugin, first install it:
npm install -D @prisma/nextjs-monorepo-workaround-plugin
Import the plugin into your
next.config.jsfile and use it inconfig.plugins:const { PrismaPlugin } = require('@prisma/nextjs-monorepo-workaround-plugin') module.exports = { webpack: (config, { isServer }) => { if (isServer) { config.plugins = [...config.plugins, new PrismaPlugin()] } return config }, }For further information, refer to our documentation to learn how to use it and open an issue if it doesn't work as expected.
Fixes and improvements
Prisma Client
Error received when connecting items in an existing one-to-many relationship on MySQL
Setting
ignoreEnvVarErrors: trueNode API QE causesdatasourceOverridesto be ignored
Prisma Migrate
sslaccept=accept_invalid_certs not working with mysql server 8.0.30
Error 08S01 (1043) -> Bad Handshake. MySQL Connection with SSL certs
db pull: add new codes for introspection warnings for views in the CLIFix Postgres introspection of partition tables false positives on inherited tables
Change
validateto returnResult<(), JsError>inWasmmodule
Join us for another "What's new in Prisma" live stream
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" live stream.
The stream takes place on YouTube on Thursday, March 2 at 5 pm Berlin | 8 am San Francisco.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.