🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Improved CLI support for connection poolers
When working with connection poolers such as the Prisma Data Proxy, Accelerate or pgBouncer, it is necessary to use a different URL to connect to the database when using Prisma Client and Prisma Migrate.
We're introducing a new datasource property directUrl
to improve this. When the directUrl
property is present, the Prisma CLI will use it to connect to the database for tasks such as introspection and migrations.
# .env
# Connection to Prisma Data Proxy. Used by Prisma Client.
DATABASE_URL="prisma://__HOST__/?api_key=__KEY__"
# Connection to the database. Used for migrations and introspection.
DIRECT_URL="postgresql://__USER__:__PASSWORD__@__HOST__:__PORT__/__DATABASE__"
// ./prisma/schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}
To learn more, refer to our documentation.
Introspection support for PostgreSQL views
We introduced initial support for database views in 4.9.0 with the addition of the view
keyword. This release introduces introspection support for PostgreSQL views. You can run prisma db pull
against your database to populate your Prisma schema with your views.
To learn more, refer to our documentation on views introspection. Try it out and let us know your thoughts in this GitHub issue.
Improved introspection for unsupported database functionality & partitioned tables
Currently, the Prisma Schema Language(PSL) does not cover the full feature sets of different database providers. For the unsupported database functionality, Prisma provides offers escape hatches like raw queries or manual editing of the migration files.
While we work on adding support for missing database functionality, e.g. database views, some of it is not fully-supported and the escape hatches fail. Objects that use unsupported properties might not be caught during introspection and raw queries might not work. Re-introspection may sometimes remove the information from the schema file and the generated migrations may be invalid or re-generate the same SQL repeatedly.
We're therefore fixing the defects and supporting the unsupported database functionalities Prisma currently doesn't support. We created a list of these features in this GitHub issue we would like to improve.
This release improves introspection support for partitioned tables in PostgreSQL and MySQL. Previously, Prisma would pick up the partitions as model
s and miss the actual main table. Prisma will now pick up the main table as a model
, not the partitions.
If you're already using partitioned tables in your database, you can use prisma db pull
to update your Prisma schema. If you're already using Prisma and want to partition a table in your database, you can:
- Create a draft migration using
prisma migrate dev --create-only
- Update the draft migration with the SQL to partition the tables
- Re-run
prisma migrate dev
to apply the draft migration to your database
Try it out and let us know what you think. If you run into an issue, feel free to create a bug report.
Smaller engine size used in Prisma CLI
In 4.8.0, we decreased the size of the engines by ~50%, which significantly impacted Prisma Client, especially in serverless environments.
In this release, we've reduced the size of Prisma CLI by removing the Introspection and Formatter engines. The introspection functionality is now served by the Migration Engine. A cross-platform Wasm module has entirely replaced the Formatter Engine. This reduces the overall installation size for Prisma CLI.
Fixes and improvements
Prisma Client
- Precompiled engine files for
aarch64-unknown-linux-musl
target (Alpine Linux on ARM, e.g. M1) - Specify the generator to use for sharing schema files in different environments
- Implement
getDmmf
as Wasm module that could be used in Prisma CLI - Client in interactive transaction is not extended
- Deeply nested objects aren't typed when clientExtensions is enabled
- Typescript issue on nested queries with clientExtensions feature
Prisma
- Introspection can't get composite primary key for partitioned table
- db pull adds redundant comment about ignored table
- Remove
prisma-fmt
formatter binary - Diagnostics currently need to be manually written for Code Action tests
- OpenSSL on Node Alpine still not working after Prisma 4.8.0 on an ARM machine
- Improved error messages on system library detection
- Remove
introspection-engine
binary from CLI - [Stopgap] Introspect partitioned tables better: Only introspect main table in a valid way, ignore partitions
- Regression:
get-platform
error for non-amd64
Alpine introduced inprisma@4.9.0
prevents using custom Prisma engines - Introspection of PostgreSQL views
- internal: use original distro and distro family in warning messages
- Failed to detect linux distro +
Error: Unknown binaryTarget debian-openssl-0.0.x and no custom engine files were provided
after upgrading from 4.8.1 to 4.9.0
Language tools (e.g. VS Code)
- Add VS Code quick fix / code action to phase out
referentialIntegrity
in favor ofrelationMode
- Auto completion of
directUrl
Credits
Huge thanks to @rintaun, @ivan, @Mini256, @yukukotani, @sandrewTx08 for helping!
📺 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, February 9 at 5 pm Berlin | 8 am San Francisco.