Here’s all you need to know about the Prisma ecosystem and community from August to December 2022.
Overview
- Releases & new features
- Features now in General Availability
- New Preview features
- General improvements
- Improved serverless experience — smaller engines size
- Improved OpenSSL 3.x support
- Native database level upserts for PostgreSQL, SQLite, and CockroachDB
- Prisma CLI exit code fixes
prisma format
now uses a Wasm module- MongoDB query fixes
- JSON filter query fixes
- Prisma extension for VS Code improvements
- Renaming of Prisma Client metrics
- Syntax highlighting for raw queries in Prisma Client
- Experimental Cloudflare Module Worker support
- Fixed “Invalid string length” error in Prisma Studio and Prisma Data Platform Data Browser
- New
P2034
error code for transaction conflicts or deadlocks
- Community
- Videos, livestreams & more
- We’re hiring
- What’s next?
Releases & new features
Our engineers have been working hard, issuing new releases with many improvements and new features. Here is an overview of what we've launched lately.
You can stay up-to-date about all upcoming features on our roadmap.
Features now in General Availability
Interactive transactions
Interactive transactions allow you to pass an async function into a $transaction
, and execute any code you like between the individual Prisma Client queries. Once the application reaches the end of the function, the transaction is committed to the database. If your application encounters an error as the transaction is being executed, the function will throw an exception and automatically rollback the transaction.
Here are some of the feature highlights we've built:
- Support for defining transaction isolation levels — from
4.2.0
- Support for the Prisma Data Proxy — from
4.6.0
Here's an example of an interactive transaction with a Serializable
isolation level:
You can now remove the interactiveTransactions
Preview feature in your schema.
Relation mode
relationMode="prisma"
is now stable for our users working with databases that don't rely on foreign keys to manage relations. 🎉
Prisma’s relation mode started as a way to support PlanetScale which does not allow you to create foreign keys for better online migration support. We transformed that into our Referential Integrity Emulation in 3.1.1
when we realised that more users could benefit from it, and then integrated it as the default mode for MongoDB, which generally does not have foreign keys. Prisma needed to use emulation to give the same guarantees.
We then realized the feature was more than just referential integrity and affected how relations work. To reflect this, we renamed the feature to relation mode and the datasource
property to relationMode
in 4.5.0
Index warnings for relationMode = "prisma"
We've added a warning to our Prisma schema validation that informs you that the lack of foreign keys might result in slower performance — and that you should add an @@index
manually to your schema to counter that. This ensures your queries are equally fast in relation mode prisma
as they are with foreign keys.
With relationMode = "prisma", no foreign keys are used, so relation fields will not benefit from the index usually created by the relational database under the hood. This can lead to slower performance when querying these fields. We recommend manually adding an index.
We also added a fix to our VS Code extension to help adding the suggested index with minimal effort:
To get started, make the following changes to your schema:
For more information, check out our updated relation mode documentation.
New Preview features
Prisma Client improvements
extendedWhereUnique
improvements ––– in4.5.0
, we introduced this Preview feature to allow filtering for non-unique properties in unique where queries. We added new rules to decide when concurrentfindUnique
queries get batched into afindMany
query. Let us know your thoughts and share your feedback on the Preview feature in this GitHub issue.fieldReference
––– field references support on query filters will allow you to compare columns against other columns. To enable column comparisons in the same table, add thefieldReference
feature flag to thegenerator
block of your Prisma Schema. Try it out and let us know what you think in this GitHub issue.filteredRelationCount
––– we've added support for the ability to count by a filtered relation. You can enable this feature by adding thefilteredRelationCount
Preview feature flag. Learn more in our documentation and let us know what you think in this issue.- Deno for Prisma Client for Data Proxy ––– we have released initial support for this feature in collaboration with the amazing team at Deno 🦕. To use Prisma Client in a Deno project, add the
deno
Preview feature flag to your Prisma schema and define a folder asoutput
(this is required for Deno). Read this guide in our documentation for a full example and individual steps. For feedback, please comment on this GitHub issue.
Prisma Client extensions
We’ve added Preview support for Prisma Client Extensions. This feature introduces new capabilities to customize and extend Prisma Client. We have opened up four areas for extending Prisma Client:
model
: add custom methods or fields to your modelsclient
: add client-level methods to Prisma Clientresult
: add custom fields to your query resultsquery
: create custom Prisma Client queries
Read about how Prisma Client just became a lot more flexible and watch a demo here:
We're excited to see what you build with them! For more information, check out our docs and let us know what you think in this GitHub issue.
Multi-schema support for CockroachDB and PostgreSQL
The ability to query and manage multiple database schemas has been a long-standing feature request from our community. We've now added Preview support for multi-schema for CockroachDB and PostgreSQL. 🎉 We’ve added support for:
- Introspecting databases that organize objects in multiple database schemas
- Managing multi-schema database setups directly from Prisma schema
- Generating migrations that are database schema-aware with Prisma Migrate
- Querying across multiple database schemas with Prisma Client If you already have a CockroachDB or a PostgreSQL database using multiple schemas, you can quickly get up and running set up multiple schemas by:
- Enabling the Preview feature in the Prisma schema
- Defining the schemas in the
schemas
property in thedatasource
block - Introspecting your database using
prisma db pull
You can further evolve your database schema using the multi-schema Preview feature by using prisma migrate dev
. For further details, refer to our documentation and let us know what you think in this GitHub issue.
PostgreSQL extension management
We’ve added support for declaring PostgreSQL extensions in the Prisma schema. The feature comes with support for introspection and migrations. You can now adopt, evolve and manage which PostgreSQL database extensions are installed directly from within your Prisma schema.
💡 This feature adds support to manage PostgreSQL extensions in Prisma schema. It does not provide additional query capabilities and datatypes in Prisma Client.
To try this feature, enable the Preview feature flag and then you will be able to use the new extensions
property in the datasource
block of your Prisma schema.
⚠️ To avoid noise from introspection, we currently only introspect the following allow-list: citext, pgcrypto, uuid-ossp, and postgis. But you can add and configure any extension to your Prisma schema manually.
Please visit our documentation to learn more about this feature or leave a comment with feedback on the GitHub issue.
Prisma Client tracing support
Tracing allows you to track requests as they flow through your application. This is especially useful for debugging distributed systems where each request can span multiple services.
With tracing, you can now see how long Prisma takes and what queries are issued in each operation. You can visualize these traces as waterfall diagrams using tools such as Jaeger, Honeycomb, or DataDog.
Read more about tracing in our announcement post and learn more in our documentation on how to start working with tracing.
Try it out and let us know what you think.
General improvements
Improved serverless experience with smaller engines size
We have decreased the size of our engine files by an average of 50%. The size of the Query Engine used on Debian, with OpenSSL 3.0.x, for example, went from 39MB to 14MB.
Additionally, we have started optimizing how the Prisma schema is loaded in Prisma Client. You should notice a considerable improvement when executing the first query if you're working with a bigger schema with many models and relations. Read more about it in the 4.8.0
release notes.
Improved OpenSSL 3.x support
Prisma now supports OpenSSL 3 builds for Linux Alpine on x86_64
architectures. This particularly impacts users running Prisma on node:alpine
and node:lts-alpine
Docker images. You can read more details about it in this GitHub comment.
We also have rewritten our OpenSSL version detection logic, making it future-proof. We now expect Prisma to support systems running with any OpenSSL 3 minor versions out of the box.
Native database level upserts for PostgreSQL, SQLite, and CockroachDB
Prisma’s upsert
is one of its most powerful and most convenient APIs. Prisma will now default to the native database upsert for PostgreSQL, SQLite, and CockroachDB whenever possible.
Get more details in the 4.6.0
release notes and try it out. If you run into any issues, don't hesitate to create a GitHub issue.
Prisma CLI exit code fixes
We've made several improvements to the Prisma CLI:
prisma migrate dev
previously returned a successful exit code (0) whenprisma db seed
was triggered but failed due to an error. We've fixed this andprisma migrate dev
will now exit with an unsuccessful exit code (1) when seeding fails.prisma migrate status
previously returned a successful exit code (0) in unexpected cases. The command will now exit with an unsuccessful exit code (1) if:- An error occurs
- There's a failed or unapplied migration
- The migration history diverges from the local migration history (
/prisma/migrations
folder) - Prisma Migrate does not manage the database' migration history
- The previous behavior when canceling a prompt by pressing Ctrl + C was returning a successful exit code (0). It now returns a non-successful,
SIGINT
, exit code (130). - In the rare event of a Rust panic from the Prisma engine, the CLI now asks you to submit an error report and exit the process with a non-successful exit code (1). Prisma previously ended the process with a successful exit code (0).
prisma format
now uses a Wasm module
Initially, the prisma format
command relied on logic from the Prisma engines in form of a native binary. After the 4.3.0
release, prisma format
will be using the same Wasm module as the one the Prisma language server uses, i.e. @prisma/prisma-fmt-wasm
, which is now visible in prisma version
command's output.
Let us know what you think. In case you run into any issues, create a GitHub issue.
MongoDB query fixes
⚠️ This may affect your query results if you relied on this buggy behavior in your application.
While implementing field reference support, we noticed a few correctness bugs in our MongoDB connector that we fixed along the way:
mode: insensitive
alphanumeric comparisons (e.g. “a” > “Z”) didn’t work (GitHub issue)mode: insensitive
didn’t exclude undefined (GitHub issue)isEmpty: false
on lists types (e.g. String[]) returned true when a list is empty (GitHub issue)hasEvery
on list types wasn’t aligned with the SQL implementations (GitHub issue)
JSON filter query fixes
⚠️ This may affect your query results if you relied on this buggy behavior in your application. We also noticed a few correctness bugs when filtering JSON values, when used in combination with the NOT condition. For example:
If you used NOT
with any of the following queries on a Json
field, double-check your queries to ensure they're returning the correct data:
string_contains
string_starts_with
string_ends_with
array_contains
array_starts_with
array_ends_with
gt
/gte
/lt
/lte
Prisma extension for VS Code improvements
The Prisma language server now provides Symbols in VS Code. This means you can now:
-
See the different blocks (
datasource
,generator
,model
,enum
, andtype
) of your Prisma schema in the Outline view. This makes it easier to navigate to a block in 1 clickA few things to note about the improvement are that:- CMD + hover on a field whose type is an enum will show the block in a popup
- CMD + left click on a field whose type is a model or enum will take you to its definition.
-
Enable Editor sticky scroll from version
1.70
of VS Code. This means you can have sticky blocks in your Prisma schema, improving your experience when working with big schema files
Make sure to update your VS Code application to 1.70, and the Prisma extension to 4.3.0
.
Renaming of Prisma Client metrics
We've renamed the metrics — counters, gauges, and histograms — returned from prisma.$metrics()
to make it a little easier to understand at a glance.
Previous | Updated |
---|---|
query_total_operations | prisma_client_queries_total |
query_total_queries | prisma_datasource_queries_total |
query_active_transactions | prisma_client_queries_active |
query_total_elapsed_time_ms | prisma_client_queries_duration_histogram_ms |
pool_wait_duration_ms | prisma_client_queries_wait_histogram_ms |
pool_active_connections | prisma_pool_connections_open |
pool_idle_connections | prisma_pool_connections_idle |
pool_wait_count | prisma_client_queries_wait |
Give Prisma Client metrics
a shot and let us know what you think in this GitHub issue
To learn more, check out our documentation.
Syntax highlighting for raw queries in Prisma Client
We’ve added syntax highlighting support for raw SQL queries when using $queryRaw``` and
$executeRaw``` . This is made possible using Prisma's VS Code extension.
Note: Syntax highlighting currently doesn't work with when using parentheses, ()
, $queryRaw()
, $executeRaw()
, $queryRawUnsafe()
, and $executeRawUnsafe()
.
If you are interested in having this supported, let us know in this GitHub issue.
Experimental Cloudflare Module Worker support
We fixed a bug that prevented the Prisma Edge Client from working with Cloudflare Module Workers. We now provide experimental support with a workaround for environment variables.
Try it out and let us know how what you think! In case you run into any errors, feel free to create a bug report.
Fixed “Invalid string length” error in Prisma Studio and Prisma Data Platform Data Browser
Many people were having issues with an "Invalid string length" error both in Prisma Studio and Prisma Data Platform Data Browser. This issue can be resolved through this workaround. The root cause of this issue was fixed and it should not occur again.
New P2034
error code for transaction conflicts or deadlocks
When using certain isolation levels, it is expected that a transaction can fail due to a write conflict or a deadlock, throwing an error. One way to solve these cases is by retrying the transaction.
To make this easier, we're introducing a new PrismaClientKnownRequestError
with the error code P2034
: "Transaction failed due to a write conflict or a deadlock. Please retry your transaction". You can programmatically catch the error and retry the transaction. Check out the 4.4.0
release notes for further details here and examples.
Community
We wouldn't be where we are today without our amazing community of developers. Our Slack has almost 50k members and is a great place to ask questions, share feedback and initiate discussions around Prisma.
Join Slack
Meetups
try-prisma
CLI
try-prisma
is a CLI tool that helps you easily get up and running with any project in the prisma/prisma-examples
repository.
The easiest way to set up a project using try-prisma
is to run the following command:
Read more on Try Prisma: The Fastest Way to Explore Prisma Examples.
Design partner program
Are you building data-intensive applications in serverless environments using Prisma? If so, you should join our Design Partner Program to help us build the tools that best fit your workflows!
The Design Partner Program aims to help development teams solve operational, data-related challenges in serverless environments. Specifically, we’re looking to build tools that help with the following problems:
- Solutions to listen and react to database changes in real time are either brittle or too complex to build and operate.
- Coordinating workflows executed via a set of isolated functions or services spreads that coordination logic across these services instead of keeping it centralized and maintainable. This adds unnecessary overhead and clutter to your business logic.
- Optimizing the data access layer for scaling performance often involves projecting data into denormalized views, or caching. These methods come with complex logic to figure out strategies for cache invalidation or preventing to use stale data.
- Building web applications on modern Serverless platforms such as Vercel or Netlify often breaks down as soon as you need to execute on any of the topics listed above. This pushes to re-platform on a traditional infrastructure, delaying projects, and losing productivity benefits offered by Vercel or Netlify.
Submit an application through our application form.
Videos, livestreams & more
What’s new in Prisma
Every other Thursday, our developer advocates, Nikolas Burk, Alex Ruheni, Tasin Ishmam, Sabin Adams, and Stephen King, discuss the latest Prisma release and other news from the Prisma ecosystem and community. If you want to travel back in time and learn about a past release, you can find all of the shows from this quarter here:
Videos
We published several videos this quarter on our YouTube channel. Check them out, and subscribe to not miss out on future videos.
- Getting up and running with TypeScript and Prisma
- How to model relationships (1-1, 1-m, m-m)
- Build a Fully Type-Safe Application with GraphQL, Prisma & React (Series)
- Database access on the Edge with Next.js, Vercel & Prisma Data Proxy
- Using
@@map
and@map
- Implementing an "exists" function
Written content
We published several articles on our blog this quarter:
- Prisma Client Just Became a Lot More Flexible
- Prisma and Platformatic Integration (Series)
- Building a REST API with NestJS and Prisma: Error Handling
- How TypeScript 4.9
satisfies
Your Prisma Workflows - Database Metrics with Prisma, Prometheus & Grafana
- Monitor Your Server with Tracing Using OpenTelemetry & Prisma
- Improving query performance with indexes using Prisma(series)
- Prisma Support for Tracing and Metrics Is Now in Preview
- Build a Fully Type-Safe Application with GraphQL, Prisma & React (series)
We also published several technical articles on the Data Guide that you might find useful:
- Introduction to testing in production
- Introduction to database caching
- Introduction to database backup considerations
- Introduction to full-text search
- Introduction to MongoDB Aggregation Framework
We’re hiring
Also, we're hiring for various roles! If you're interested in joining us, check out our jobs page.
Explore Jobs
What’s next?
The best places to stay up-to-date about what we are currently working on are our GitHub issues and our public roadmap.
You can also engage in conversations in our Slack channel and start a discussion on GitHub or join one of the many Prisma meetups around the world.
Don’t miss the next post!
Sign up for the Prisma Newsletter