Implicit relation tables always have `onDelete CASCADE`, this should be configurable.
See original GitHub issueHi, currently you set the onDelete behaviour of generated associate tables in M:N relationships to CASCADE, e.g.:
CREATE TABLE "public"."_UserRoles" (
"A" text NOT NULL,
"B" text NOT NULL,
CONSTRAINT "_UserRoles_A_fkey" FOREIGN KEY ("A") REFERENCES "public"."Role"("id") ON DELETE CASCADE,
CONSTRAINT "_UserRoles_B_fkey" FOREIGN KEY ("B") REFERENCES "public"."User"("id") ON DELETE CASCADE
);
It would be great if we could configure it. I have a situation, when I would like to prohibit deletions of a Role if there exists an association to it through UserRole.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Referential actions - Prisma
Referential actions let you define the update and delete behavior of related models on the database level.
Read more >Cascade Delete - EF Core | Microsoft Learn
Configuring cascading behaviors triggered when an entity is deleted or severed from its principal/parent.
Read more >Good explanation of cascade (ON DELETE/UPDATE) behavior
ON DELETE CASCADE : if a row of the referenced table is deleted, then all matching rows in the referencing table are deleted....
Read more >13.1.20.5 FOREIGN KEY Constraints - MySQL :: Developer Zone
If a FOREIGN KEY clause is defined on both tables in a foreign key relationship, making both tables a parent and child, an...
Read more >Foreign key constraint may cause cycles or multiple cascade ...
Introducing FOREIGN KEY constraint 'FK74988DB24B3C886' on table 'Employee' may cause cycles or multiple cascade paths. Specify ON DELETE NO ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This has now been released as a preview feature behind a preview feature flag. You can read about it in the release notes for 2.26.0: https://github.com/prisma/prisma/releases/tag/2.26.0 If you have any feedback, please use this issue: https://github.com/prisma/prisma/issues/7816
This is the default the query engine (prisma client) relies on - the plan is to make this configurable, but it is pending on product work currently.