-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update prisma monorepo to v2.26.0 (minor) #6027
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/keystonejs/keystone-next-docs/BEfmig9iHkr5st9zV9qnBCBnHtSt |
🦋 Changeset detectedLatest commit: b0fd589 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
ee687e2
to
7fc74a5
Compare
1445e19
to
5f8e377
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR contains the following updates:
2.25.0
->2.26.0
2.25.0
->2.26.0
2.25.0
->2.26.0
2.25.0
->2.26.0
Release Notes
prisma/prisma
v2.26.0
Compare Source
Today, we are excited to share the
2.26.0
stable release 🎉🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Major improvements & new features
Referential Actions now enable cascading deletes and updates (Preview)
In this release we are introducing a new feature in Preview which enables fine-grained control over referential actions
ON DELETE
andON UPDATE
for the foreign keys supporting relations in Prisma models.Current behavior
Until now, Prisma created a foreign key for each relation between Prisma models with the following defaults:
ON DELETE CASCADE ON UPDATE CASCADE
. In addition, when invoking thedelete()
ordeleteAll()
methods, Prisma Client performs runtime checks and will prevent the deletion of records on required relations if there are related objects referencing it, effectively preventing the cascade delete behavior. When using raw SQL queries for deletion, Prisma Client won't perform any checks, and deleting a referenced object will effectively cause the deletion of the referencing objects.Example:
prisma.user.delete(...)
andprisma.user.deleteAll()
will fail if the user has posts.Using raw SQL, e.g. using
$queryRaw()
to delete the user will trigger the deletion of its posts.New behavior
The feature can be enabled by setting the preview feature flag
referentialActions
in thegenerator
block of Prisma Client in your Prisma schema file:With the feature enabled, the behavior is now the following:
prisma db push
, and introspection will set these in the database schema, e.g.@relation(... onDelete: SetNull)
will set translate toON DELETE SET NULL
on the corresponding foreign key. See Syntax section below.onDelete
oronUpdate
attributes in@relation
are not present, default values are used:ON DELETE RESTRICT
(NO ACTION
on SQL Server) for required relationsON DELETE SET NULL
for optional relationsON UPDATE CASCADE
for all relations regardless if optional or required.prisma db push
, and introspection will rely on the syntax and default values above to keep the referential actions between Prisma schema and database schema in sync.delete()
ordeleteAll()
methods. Deleting referenced objects will succeed or not depending on the underlying foreign keys of relations, e.g. by default deletion will be prevented by the database because it's set toON DELETE RESTRICT
, but will succeed if set toON DELETE CASCADE
.onDelete
oronUpdate
attributes in the Prisma schema, the next time the database is updated with Prisma Migrate orprisma db push
, the database schema will be updated to use the default values on all foreign keys,ON DELETE RESTRICT ON UPDATE CASCADE
(ON DELETE NO ACTION ON UPDATE CASCADE
on SQL Server).Please note that until then, if the database schema is managed using Prisma Migrate or
prisma db push
, the existing defaults are probably in place (ON DELETE CASCADE ON UPDATE CASCADE
), and this could lead to deletion of records in conditions where a deletion was previously prevented by Prisma Client until the foreign key constraints are updated.Syntax
The semantics of
onDelete
andonUpdate
are almost exactly how SQL expressesON UPDATE
andON DELETE
. For the example below:User
) of aPost
is deleted (onDelete
), delete allPost
rows that are referencing the deletedUser
(Cascade
).id
field of the relatedUser
is updated, also updateauthorId
of allPost
s that reference thatUser
.Possible keywords for
onDelete
andonUpdate
are:Cascade
,Restrict
(except SQL Server),NoAction
,SetNull
,SetDefault
.If you run into any questions or have any feedback, we're available in this issue.
Limitations
SetNull
on a required relation will lead to database errors when deleting referenced records because the non-nullable constraint would be violated.prisma init
now accepts a--datasource-provider
argumentThe
prisma init
command now accepts a--datasource-provider
argument that lets you configure the defaultprovider
for the initially generateddatasource
block in your Prisma schema. The possible values for this argument are equivalent to the allowed values for theprovider
field ondatasource
blocks:postgresql
(default)mysql
sqlite
sqlserver
(Preview, needs themicrosoftSqlServer
preview feature flag)Here's an example that shows how to configure the initial Prisma schema skeleton with a SQLite database:
Node-API Improvements
The Prisma Client currently communicates to Prisma's Query Engine over either HTTP or Unix domain sockets. After some experimentation, we realized we can improve this communication overhead by using Node-API, which provides direct memory access across processes.
We've been working the last couple of weeks to get ready to make Node-API the default way we communicate with the Query Engine. To prepare for this change, we fixed a bunch of bugs and we'd love for you to give it another try:
Right now we're still compiling benchmarks, but you should see a nice speed boost by opting into Node-API. You can reach us in this issue if you run into anything!
Fixes and improvements
Prisma Client
join
raw query helper with SQL Servergenerate
givesTypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Object
orTypeError: outputDir.endsWith is not a function
error and no helpful outputQuery engine exited with code 101 - thread 'main' panicked at 'Could not open datamodel file "/schema.prisma"...'
Engine is not yet connected.
CI test with Node-APIPrisma Migrate
onDelete CASCADE
, this should be configurable.Introducing FOREIGN KEY constraint '...' on table '...' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Prisma
binaryTargets: env("..")
insidegenerator client
sectionCredits
Huge thanks to @B2o5T for helping!
🌎 Prisma Day is happening today!
Prisma Day is a two-day event of talks and workshops by members of the Prisma community, on modern application development and databases. It's taking place June 29-30th and is entirely online.
We look forward to seeing you there!
📺 Join us for another "What's new in Prisma" livestream
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" livestream.
The stream takes place on Youtube on Thursday, July 01 at 5pm Berlin | 8am San Francisco.
Configuration
📅 Schedule: "before 7am on Tuesday,before 7am on Wednesday" in timezone Australia/Sydney.
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Renovate will not automatically rebase this PR, because other commits have been found.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
This PR has been generated by WhiteSource Renovate. View repository job log here.