Replies: 2 comments 1 reply
|
Is it possible to take a look at what is going on trying to use 2.26.0 with pnpm? version 2.23.0 works just fine and in every project I use prisma I had to pin the version to 2.23.0 Minimal repo reproducing this issue with some instructions and screenshots in the README: |
|
Hi there, To keep our discussions organized and focused on the most relevant topics, we’re reviewing and tidying up our backlog. As part of this process, we’re closing discussions that haven’t had any recent activity and appear to be outdated. If this discussion is still important to you or unresolved, we’d love to hear from you! Feel free to reopen it or start a new one with updated details. For more details about our priorities and vision for the future of Prisma ORM, check out our latest blog post: https://www.prisma.io/blog/prisma-orm-manifesto. Thank you for your understanding and being part of the community! |
Uh oh!
There was an error while loading. Please reload this page.
Today, we are excited to share the
2.26.0stable 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 DELETEandON UPDATEfor 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
referentialActionsin thegeneratorblock 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 NULLon the corresponding foreign key. See Syntax section below.onDeleteoronUpdateattributes in@relationare not present, default values are used:ON DELETE RESTRICT(NO ACTIONon SQL Server) for required relationsON DELETE SET NULLfor optional relationsON UPDATE CASCADEfor 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.onDeleteoronUpdateattributes 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 CASCADEon 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
onDeleteandonUpdateare almost exactly how SQL expressesON UPDATEandON DELETE. For the example below:User) of aPostis deleted (onDelete), delete allPostrows that are referencing the deletedUser(Cascade).idfield of the relatedUseris updated, also updateauthor_idof allPosts that reference thatUser.Possible keywords for
onDeleteandonUpdateare:Cascade,Restrict(except SQL Server),NoAction,SetNull,SetDefault. For a detailed reference, please read our docs.Limitations
SetNullon a required relation will lead to database errors when deleting referenced records because the non-nullable constraint would be violated.prisma initnow accepts a--datasource-providerargumentThe
prisma initcommand now accepts a--datasource-providerargument that lets you configure the defaultproviderfor the initially generateddatasourceblock in your Prisma schema. The possible values for this argument are equivalent to the allowed values for theproviderfield ondatasourceblocks:postgresql(default)mysqlsqlitesqlserver(Preview, needs themicrosoftSqlServerpreview 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
joinraw query helper with SQL ServergenerategivesTypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of ObjectorTypeError: outputDir.endsWith is not a functionerror 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 clientsectionCredits
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.
This discussion was created from the release 2.26.0.
All reactions