question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implicit relation tables always have `onDelete CASCADE`, this should be configurable.

See original GitHub issue

Hi, 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
janpiocommented, Jun 29, 2021

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

1reaction
tomhoulecommented, May 20, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found