Skip to content
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

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

Closed
tomitrescak opened this issue Jan 13, 2020 · 6 comments

Comments

@tomitrescak
Copy link
Contributor

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.

@tomitrescak tomitrescak changed the title Associate tables have always onDelete CASCADE, this should be configurable. Associative tables have always onDelete CASCADE, this should be configurable. Jan 13, 2020
@janpio janpio transferred this issue from prisma/prisma Jan 13, 2020
@pantharshit00
Copy link
Contributor

Right now as a workaround you can manually edit the schema but I agree we should make this configurable.

@janpio janpio changed the title Associative tables have always onDelete CASCADE, this should be configurable. Implicit relation tables always have onDelete CASCADE, this should be configurable. May 20, 2020
@tomhoule
Copy link
Contributor

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.

@tomhoule tomhoule transferred this issue from prisma/migrate Nov 5, 2020
@tomhoule

This comment has been minimized.

@tomhoule tomhoule added kind/feature A request for a new feature. team/product labels Nov 5, 2020
@janpio janpio added the team/schema Issue for team Schema. label Mar 23, 2021
@Jolg42
Copy link
Member

Jolg42 commented Mar 25, 2021

Related #4711

@pimeys
Copy link
Contributor

pimeys commented Jun 22, 2021

You can configure this from the next version of Prisma (2.26.0). PR merged today in prisma/prisma-engines#1947

Please read the proposal in #6996

Instructions on how to use this, and a place to give feedback: #7816

@pimeys pimeys closed this as completed Jun 22, 2021
@Jolg42 Jolg42 added this to the 2.26.0 milestone Jun 23, 2021
@janpio
Copy link
Member

janpio commented 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: #7816

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants