nestjs-boilerplate
nestjs-boilerplate copied to clipboard
fix(deps): update prisma monorepo to v4 (major)
This PR contains the following updates:
Package | Change | Age | Adoption | Passing | Confidence |
---|---|---|---|---|---|
@prisma/client (source) | ^3.1.1 -> ^4.0.0 |
||||
prisma (source) | ^3.1.1 -> ^4.0.0 |
Release Notes
prisma/prisma
v4.11.0
🌟 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 jsonProtocol
Preview 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 jsonProtocol
to 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 pull
against 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.js
file and use it in config.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
- Prisma hangs when javascript is minified
- Issue with prisma failing to locate schema file in monorepo
- NextJS try to open "schema.prisma" at wrong path.
-
pnpm workspace + nextjs:
ENOENT: no such file or directory, open '...\.next\server\pages\api\schema.prisma'
- next.js ENOENT trying to open schema.prisma
-
Error with custom output in NPM monorepo:
Error: ENOENT: no such file or directory, open 'schema.prisma'
- Error with custom output in Turborepo using Blitz.js: Error: ENOENT: no such file or directory, open '<...>/schema.prisma'
- Upsert fails on Postgres with list column.
- Error received when connecting items in an existing one-to-many relationship on MySQL
-
ENOENT
with custom output and ESM module in NPM monorepo (including Nextjs):no such file or directory, open /.../schema.prisma...
-
Setting
ignoreEnvVarErrors: true
Node API QE causesdatasourceOverrides
to be ignored - PCE: Support query extensions for raw queries
Prisma Migrate
- sslaccept=accept_invalid_certs not working with mysql server 8.0.30
- Error 08S01 (1043) -> Bad Handshake. MySQL Connection with SSL certs
- Introspection of MySQL views
- Introspection of SQL Server views
- Introspection of CockroachDB views
-
db pull
: add new codes for introspection warnings for views in the CLI - Figure out where getDMMF is used for validation
-
Error when
directUrl
isprisma://
connection string -
4.10.0, unexpected:
errorCode: 'P1012' PrismaClientInitializationError: error: Environment variable not found: DATABASE_URL.
- Validation output is now always colored, also in CI
-
Prisma Client falsely validates
directUrl
env var value, leading to validation error (Affects PDP/Data Proxy and normal Engine) - Fix Postgres introspection of partition tables false positives on inherited tables
- Support openSUSE Tumbleweed
-
Change
validate
to returnResult<(), JsError>
inWasm
module - (internal): add unit tests for path-specific libssl version parsing
Credits
Huge thanks to @KhooHaoYit, @rintaun, @ivan, @Mini256, @Lioness100, @yukukotani, @sandrewTx08, @fubhy, @zachtil, @unflxw, @Mosaab-Emam 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, March 2 at 5 pm Berlin | 8 am San Francisco.
v4.10.1
Today, we are issuing the 4.10.1
patch release.
Fixes in Prisma Client
- Prisma Client falsely validates directUrl env var value, leading to validation error (Affects PDP/Data Proxy and normal Engine)
- 4.10.0, unexpected: errorCode: 'P1012' PrismaClientInitializationError: error: Environment variable not found: DATABASE_URL.
v4.10.0
🌟 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 in[email protected]
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.
v4.9.0
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Initial support for database views (Preview)
This release introduces a new keyword, view
, behind the views
Preview feature flag. You can manually add a view
to your Prisma schema, which is ignored when running migrations. This is a small step forward but should already be helpful to many of you depending on workarounds and shell scripts to work with views and Migrate.
Here is an example usage of views
:
generator client {
provider = "prisma-client-js"
previewFeatures = ["views"]
}
view UserInfo {
id Int @​id
// from the User model
email String
name String
// from the Profile model
bio String
}
model User {
id Int @​id @​default(autoincrement())
email String @​unique
name String?
profile Profile?
}
model Profile {
id Int @​id @​default(autoincrement())
bio String
user User @​relation(fields: [userId], references: [id])
userId Int @​unique
}
To learn more, head to our documentation. Try it out and let us know your thoughts on this GitHub issue.
Multi-schema support for SQL Server (Preview)
We're thrilled to share that this release adds Preview support for multi-schema for SQL Server.
This release adds 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 SQL Server database using multiple schemas, you can quickly get up and running and 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.
Prisma Client Extensions improvements
In this release, we've made a number of improvements to the Prisma Client Extensions Preview feature:
-
Retrieving the current model name at runtime You can now get the name of the current model at runtime using
Prisma.getExtensionContext(this).name
. You might use this to write out the model name to a log, to send the name to another service, or to branch your code based on the model. You can learn more about this in our docs. -
Improved type safety when defining custom model methods Prisma Client now provides a set of type utilities that tap into input and output types. They are fully dynamic, which means they adapt to any given model and schema. You can use them to improve your custom model methods' auto-completion. This is especially useful in shared extensions. Learn more about this in our docs.
Let us know what you think in this GitHub issue and in case you run into any issues, please create a bug report.
Introspection and Migration engine improvements
In this release, we moved the Introspection Engine (responsible for prisma db pull
) which the Migration Engine will now serve. Previously, the Introspection Engine was stand-alone.
Let us know what you think in this GitHub issue and in case you run into any issues, please create a bug report.
MongoDB WriteConflict
bug fix
This version also comes with a notable bug fix: In our MongoDB provider, any queries that are returned with a WriteConflict
error Prisma now will retry the query, similar to how other MongoDB drivers and clients do.
Prisma plugin for JetBrains IDEs
If you are using a JetBrains IDE the team over at JetBrains recently released an official Prisma plugin in their Plugin Marketplace.
Thank you, @JetBrains, for working on this! Next to our VS Code extension for Prisma and our general language server, which works in many editors, most relevant editors should now be covered.
Accelerate (Early Access)
We’re thrilled to announce Early Access to Accelerate.
Accelerate is a global database cache. It is available in 280 locations and has built-in connection pooling for serverless apps. You can make your queries up to 1000 times faster on any Prisma-supported database, reducing your query response times.
Join the waiting list for Accelerate here.
Fixes and improvements
Prisma
- Feature Request: Jetbrains (IntelliJ IDEA, Webstorm) Plugin
- Misleading 'We need to reset the PostgreSQL database' when using PostgreSQL schemas
- Solve "P1012 Introspection failed" errors on Windows CI
- support NanoID
-
Create CI worker without a proper
openssl
orlibc
installation to improve snapshot testing suite - db pull --url with an invalid url produces a misleading error message
- (re)-Introspection errors have a misleading error message
- multi-schema + introspection: rename models and enums to avoid name collisions
-
multiSchema + introspection: add
--schemas
param to thedb pull
command - Cross schema reference with foreign key not working in 4.7.0+
-
Handle missing
schemas
property different when cross schema references are detected (whenmultiSchema
preview feature is enabled) -
db pull
withmultiSchema
enabled andschemas
defined, outputspublic
in CLI message anyway - Remove DML dependency from MongoDB introspection
- I want short unique id. UUID, CUID are too long
-
Completions: for
schemas
property indatasource
-
Completions
@@​schema
attribute -
OS Support: improve SSL detection on
debian
distros -
multiSchema
: addschemas
property togetConfig
output -
multiSchema:
migrate reset
with sqlserver does not delete second schema -
Prisma 4.9.x (dev version) broke
openssl
detection for Linux distros besides Alpine and Debian-based distros, like RHEL -
Wrong db pull warning with multiSchema preview feature, it says that
These enums were enriched with
@@mapinformation taken from the previous Prisma schema.
but the schema file datamodel is actually empty. -
PSL: Recognize the
view
keyword - previewFeatures = ["multiSchema"] Error when doing db pull
-
#17126 broke the
platform-serverless-vercel/vercel-cli
ecosystem tests -
When
distro
is undefined, the output ofldconfig
is ignored because of thesed: -e expression #​1, char 7: unknown option to
s'` silent error
Prisma Client
- Detect absense of openssl and inform the user about it
- [email protected] - "RangeError: Maximum call stack size exceeded" when clientExtensions enabled
- Prisma 4.8 produces conflicting typescript types for custom many to many relations
-
Using findUnique on 4.8.0 with nested
where
andinclude
produces an object that doesn't include entities you specify ininclude
- Error: Maximum call stack size exceeded is thrown after I used clientExtensions as preview feature.
-
MongoDB: Using
delete
on a one-to-one relation while updating removes other relations - Promise types are not unwrapped properly when using async/await in WebStorm
- Deeply nested objects aren't typed when clientExtensions is enabled
Prisma Migrate
Language tools (e.g. VS Code)
- Improve local development workflow and update documentation
- Integer.MAX_VALUE is not portable across clients
-
Quick Fix: add
@@​schema
attribute to model / enum - Completions: from the list of available schema namespaces
-
Recognizing the
view
keyword
Prisma Engines
-
update napi dependencies from
2.9.1
to2.10.1
-
me/ie rewiring: add
introspect
tests tomigration-engine
Credits
Huge thanks @rintaun, @ivan, @Mini256, @fubhy, @unflxw, @Mosaab-Emam 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, January 26 at 5 pm Berlin | 8 am San Francisco.
v4.8.1
Today, we are issuing the 4.8.1
patch release.
Fix in Prisma Client
v4.8.0
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Improved serverless experience — smaller engines size
In this release, 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. We will also remove some smaller engines to decrease the total size in future versions.
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.
We will continue investing in this direction in the next releases and further improve the experience with Prisma and serverless environments.
Multi-schema support for CockroachDB (Preview)
We're pleased to share that this release adds Preview support for multi-schema for CockroachDB. 🎉
This release adds 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 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.
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. The images are based on an Alpine version that ships with OpenSSL 3.0.x, which isn’t compatible with OpenSSL 1.1.x (already supported by Prisma). 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.
Fixes and improvements
Prisma
- Migrate: @dbgenerated with @db.Time(0) keeps generating new migrations
-
Error parsing attribute "@@index": The Gin index field type
Uuid
has no default operator class. - UTF-8 Error: index is not a char boundary
- Error in migration engine. Reason: entered unreachable code
- Regression in enum default value handling in 4.7.0
- Regression in relation field name deduplication
-
multiSchema:
migrate reset
only resets first schema - Cross schema reference with foreign key not working in 4.7.0.
-
Support SQL Server in
multiSchema
introspection -
migrate dev
does not detect drift between database schema and migration history formultiSchema
- Bad credentials when downloading using @prisma/fetch-engines
- multiSchema: migrate dev fails to apply cleanly to shadow database after custom migration renames table in secondary schema
Prisma Migrate
- Prisma db migration always altering my table contains mysql TIME data type inside of it
- Prisma migration fails with postgres
-
Migrate Dev CMD Issue when using
multiSchema
preview feature with MySQL
Prisma Client
- Prisma 4.3.1 distribution is bundling a libquery_engine
-
enum fields are missing in select's type when
clientExtensions
preview feature is used -
$extends
TS error: "Inferred type of this node exceeds the maximum length the compiler will serialize" with"declaration": true
intsconfig
- Regression bug: batched findUniqueOrThrow queries throw 'Field does not exist on enclosing type.'
-
Prisma Client Extensions:
args
isundefined
- Support OpenSSL 3.0 for Alpine Linux
-
console.log
outputs incorrect value whenresult
extensions are used - 4.6.0 and newer does not let me spy using vitest.
- Investigate memory issues on Windows
- [email protected] - "RangeError: Maximum call stack size exceeded" when clientExtensions enabled
- Unique constraint error when connecting an item in a 1-1 relation that is already connected
- Error when using "multiSchema" with custom database schema and implicit Many To Many relation
- binaries.prisma.sh not accessible via IPv6
-
Nested disconnect fails with
extendedWhereUnique
on SQL
Language tools (e.g. VS Code)
-
Auto completion suggests
@map
although already present - Update message for detecting both Stable and Insiders in workspace
- Update to use correct form of criteri(a/on)
-
Extra
'
in optional arguments context
Prisma Engines
- Use correct forms of "criterion" (singular) and "criteria" (plural)
- Only use buildjet action runner where needed
-
Bug:
@@​schema
attribute should always be required whenschemas
is defined in the datasource
Credits
Huge thanks to @ivan, @Mini256, @cmd-johnson for helping!
Prisma Help Center (New)
We recently just launched our Help Center that you can use to find resources and get help from our support team for both the Prisma ORM and the Prisma Data Platform.
Check it out, and let us know what you think.
📺 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, December 22 at 5 pm Berlin | 8 am San Francisco.
v4.7.1
Today, we are issuing the 4.7.1
patch release.
Fixes in Prisma Client
-
Enum fields are missing in select's type when
clientExtensions
preview feature is used -
console.log
outputs incorrect value whenresult
extensions are used -
"Field does not exist on enclosing type" error is thrown in
findUniqueOrThrow
-
Prisma Client Extensions:
args
isundefined
v4.7.0
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Highlights
Interactive transactions are now Generally Available
After an extensive Preview phase and lots of great feedback from our community, we're excited to announce that interactiveTransactions
is now Generally Available and production ready! 🚀
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:
await prisma.$transaction(
async (prisma) => {
// Your transaction...
},
{
isolationLevel: Prisma.TransactionIsolationLevel.Serializable,
maxWait: 5000,
timeout: 10000,
}
)
You can now remove the interactiveTransactions
Preview feature in your schema.
Relation mode is Generally Available
This release marks relationMode="prisma"
as 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"
In this release, 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:
If you are currently using the Preview feature flag to enable relation mode, you can now remove referentialIntegrity
from the previewFeatures
in your generator client
block in your Prisma schema.
For more information, check out our updated relation mode documentation.
Prisma Client Extensions (Preview)
This release adds Preview support for Prisma Client Extensions. This feature introduces new capabilities to customize and extend Prisma Client. Today we are opening up four areas for extending Prisma Client:
-
model
: add custom methods or fields to your models -
client
: add client-level methods to Prisma Client -
result
: add custom fields to your query results -
query
: create custom Prisma Client queries
Prisma Client Extensions are self-contained scripts that can tweak the behavior of models, queries, results, and the client (Prisma Client) as a whole. You can associate a single or multiple extensions with an extended client to mix and match Prisma to your needs.
Prisma Client Extensions enables many use cases such as defining virtual fields, custom validation, and custom queries.
It also enables you to share your client extensions with others and import client extensions developed by others into your project.
For example, given the following schema:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["clientExtensions"]
}
model User {
id Int @​id @​default(autoincrement())
email String @​unique
firstName String?
lastName String
}
You can create a computed field called fullName
as follows:
import { PrismaClient } from "@​prisma/client"
const prisma = new PrismaClient()
.$extends({
result: {
user: {
fullName: {
// the dependencies
needs: { firstName: true, lastName: true },
compute(user) {
// the computation logic
return `${user.firstName} ${user.lastName}`
},
},
},
},
})
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 PostgreSQL (Preview)
We're pleased to announce that this release adds support for multi-schema support for PostgreSQL. The ability to query and manage multiple database schemas has been a long-standing feature request from our community.
This release adds support for the following:
- 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 PostgreSQL database using multiple schemas, you can quickly get up and running using prisma db pull
— on enabling the Preview feature and specifying the schemas in the datasource
block similar to the example below.
You can get started with defining multiple schemas in your Prisma schema as follows:
generator client {
provider = "prisma-client-js"
previewFeatures = ["multiSchema"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
schemas = ["base", "transactional"]
}
model User {
id Int @​id
orders Order[]
@​@​schema("base")
}
model Order {
id Int @​id
user User @​relation(fields: [id], references: [id])
user_id Int
@​@​schema("transactional")
}
Then generate and apply the changes to your database with prisma migrate dev
.
We want to thank all our users for helping us design the feature since the early proposal on GitHub up to our current Preview release.
For further details, refer to our documentation and let us know what you think in this GitHub issue.
Request for feedback
Our Product team is currently running a survey for designing Database Views support for Prisma and we would appreciate your feedback.
Fixes and improvements
Prisma Client
-
RangeError: Invalid count value
duringnpx prisma generate
withDEBUG=*
on integration build - When rejectOnNotFound is used, chaining deeper into a related table still throws if it doesn't find anything
-
Stabilize
referentialIntegrity
-
Some errors are obfuscated by interactive transactions when using
binary
engine - Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Expired' P2028
- The error is incorrectly pointed out when using the $transaction method
- Client: using update + connect throws an error on an idempotent operation
-
findFirstOrThrow / findUniqueOrThrow errors are not reported via
error
event - wrong error message/header on multiple table upsert using transaction
- Args are out of sync with the action type for count when creating prisma middeware
- “Transaction API error: Transaction not found”
-
Add
Prisma.TransactionClient
todefault-index.d.ts
- RangeError: Invalid count value during prisma generate
-
Prisma Client regression bug after upgrading to 4.6.0:
findMany
errors withPANIC: index out of bounds: the len is 0 but the index is 0
-
upsert()
with nested selection errors withcalled
Option::unwrap()on a
Nonevalue
in 4.6.0 - Bug(qe): errors don't get logged
- Downloading binaries of 4.6.1 fails with wrong sha256 checksum
-
Calling
findUnique
concurrently with different key order causes one of them to return null -
No way to catch error in
findUniqueOrThrow
via middleware -
Test implicit m:n in relation mode
prisma
/ Reproduction test for prisma#16390
Prisma
- [Multi Schema] Same model map different schema
-
Schema: add deprecation warning for datasource property
referentialIntegrity
(renamed torelationMode
) - Error in migration engine. Reason: [migration-engine/connectors/sql-migration-connector/src/sql_renderer/postgres_renderer.rs:944:22] We should only be setting a changed default if there was one on the previous schema and in the next with the same enum.
-
db pull
withmultiSchema
error on schema with 2 models with the same table name but in a different schema - Prisma 4.6.0 drops and recreates enum field when running db push even if the field has not changed
- @@map not working on postgress enums starting version 4.6.0
-
relationMode
: make feature GA -
Add
SetDefault
validation error with warnings whenprovider = "mysql"
andrelationMode = "foreignKeys" | default
-
Polish
relationMode
validation warning messages -
Add linting/validation warnings for
prisma validate
&prisma format
Prisma Migrate
-
What happen with
prisma migrate dev
- Prisma complains when enum types are not declared in alphabetical order
Language tools (e.g. VS Code)
-
Dim models that are
@@​ignore
d and fields that are@ignore
d -
Recommend adding indices to foreign keys when
referentialIntegrity = "prisma"
-
PostgreSQL only: Add autocompletion in the datasource block for
extensions
whenpostgresqlExtensions
preview feature is set -
language-tools:
relationMode
GA - remove preview feature condition -
feat: for
relationMode="prisma"
, for@relation
: add a warning if there is no index on the field(s) -
feat: Quick Fix -
relationMode
: missing foreign keys' indexes
Prisma Engines
Credits
Huge thanks to @cmd-johnson, @jsoref, @miguelgargallo for helping!
Prisma Data Platform
We're working on the Prisma Data Platform — a collaborative environment for connecting apps to databases. It includes the following:
- Data Browser for navigating, editing, and querying data
- Data Proxy for your database's persistent, reliable, and scalable connection pooling.
- Query Console for experimenting with queries
Try it out. Let us know what you think!
📺 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, December 1 at 5 pm Berlin | 8 am San Francisco.
v4.6.1
Today, we are issuing the 4.6.1
patch release.
Fixes in Prisma Client
-
Prisma Client regression bug after upgrading to 4.6.0:
findMany
errors withPANIC: index out of bounds: the len is 0 but the index is 0
-
upsert()
with nested selection errors withcalled
Option::unwrap()on a
Nonevalue
in 4.6.0
Fix in Prisma Migrate
v4.6.0
[Compare Source](https://togithub.com/prisma/prisma/compare/4.5.0...
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
- [ ] If you want to rebase/retry this PR, check this box
This PR has been generated by Mend Renovate. View repository job log here.