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

Support for configuring referential actions (on delete, on cascade) in Prisma Schema Language #2810

Closed
janpio opened this issue Jun 20, 2020 · 43 comments · Fixed by prisma/prisma-engines#1947

Comments

@janpio
Copy link
Member

janpio commented Jun 20, 2020

Problem

Currently Prisma Schema does not support a way to define cascading deletes. But people want to use that functionality.

Suggested solution

Define, implement and document a syntax for cascading deletes.

Alternatives

Set the cascading deletes on the database manually, but that has problems like #2057

Additional Information

@jechazelle
Copy link

Do you know when this feature will be release (milestone) ? Thank you ! :-)

@janpio
Copy link
Member Author

janpio commented Jun 24, 2020

No, we do no have a release date yet.
But we see the 👍 and will take this into consideration.
(We actually just talked about it in a meeting, so it really is top of mind for us.)

@aakashkag
Copy link

aakashkag commented Jul 2, 2020

Hello Prisma team.
Any plan to fix this issue. It's pending from long time. its' very important feature.
Thanks

@macrozone
Copy link

i also think that is one of the biggest problem right now in prisma (besides missing migrations)

@Albert-Gao
Copy link

https://paljs.com

This is the community solution

@geosigno
Copy link

Hello, any update on that feature?

@thebiglabasky
Copy link

Hi, this is planned, but will likely be tackled once migrate has reached a stable state, which is our biggest priority right now. Since cascade delete lean a lot on the schema changes, we preferred to go this way.
That's high on our list though, so stay tuned!

@albertoperdomo albertoperdomo added the team/schema Issue for team Schema. label Nov 25, 2020
@himalayaahuja
Copy link

When will migrate reach a stable state ?? :(

@premkumar5012002
Copy link

premkumar5012002 commented May 19, 2021

when this feature will be available

@tomhoule
Copy link
Contributor

Note that there currently is an open proposal for this feature: #6996

@tomhoule
Copy link
Contributor

Feedback on the linked issue is very much wanted

@pedrovrima
Copy link

In case someone needs a workaround, here is a light package that doesn't require changes your schema:

https://www.npmjs.com/package/prisma-cascade-delete

@janpio janpio changed the title Support for configuring cascading deletes in Prisma Schema Language Support for configuring referential actions (on delete, on cascade) in Prisma Schema Language Jun 8, 2021
@PS1TD
Copy link

PS1TD commented Jun 11, 2021

Can't wait for this feature to be released. A lot of complex projects rely heavily on proper cascading deletes including mine. It would be awesome to have this built in instead of having to deal with community workarounds. Keep up the great work Prisma team!

@janpio
Copy link
Member Author

janpio commented Jun 11, 2021

Quick update in that direction: We are actively working on implementation of the proposal spelled out in #6996 - so this is happening. If you can take another look at that proposal and leave your feedback, that would be appreciated.

@Billano
Copy link

Billano commented Jun 16, 2021

@janpio any idea on when will the feature be release? (a rough estime works) btw, thanks!!

@tomhoule tomhoule modified the milestones: 2.25.0, 2.26.0 Jun 17, 2021
@janpio
Copy link
Member Author

janpio commented Jun 17, 2021

No ETA, but definitely more weeks than quarters away.

@janpio
Copy link
Member Author

janpio commented Jun 22, 2021

Instructions on how to use this, and a place to give feedback, will be here when it is shipped in a version: #7816

@FlorianWendelborn
Copy link

@janpio FWIW, the documentation still points to this issue instead of the feedback issue. Not sure if that’s expected or not so I’m raising it here.

@cyrus-za
Copy link
Contributor

Yep @FlorianWendelborn I came to this issue form docs. I see its in preview now on #7816 but there's no instructions on how to use it.

@pimeys
Copy link
Contributor

pimeys commented Jun 25, 2021

It is available in the dev channel, but is not tested yet by others than us the devs. There's also the documentation effort going on: this will be a breaking change and users need to understand the change properly before we can talk about it more.

It is under the previewFeature flag referentialActions in the dev channel, but please keep in mind a possible data loss if just updating without first doing a re-introspection and manually going through all relations, changing the action from cascade to restrict if needed.

So, just wait until next Tuesday's release 2.26.0 for docs and info, or if accepting a risk of data loss, you can try the dev channel...

@janpio
Copy link
Member Author

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

Successfully merging a pull request may close this issue.