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
Enable cascading delete behaviour with onDelete: CASCADE #4711
Comments
I am looking very much forward for this.
When ever i want to delete a user who owns a team, i have to delete the team first. |
Hey guys, I just wanted to check on the status of this feature. I'm having trouble right now as I have 2 models with a 1 to 1 relation, and when I delete 1 I want it to delete the other. My schema is this: model User {
id ID
gameLibrary UserGameLibrary
}
model UserGameLibrary {
id ID
user USER
} Currently, I can't delete a |
Did you solve this ? |
This is a really important one. Can it be prioritized? Where can we expect this feature? |
I feel this is a really important feature since it is a fundamental requirement for any mature project with lots of relations. I really hope this gets solved soon. |
In the meantime, has anyone found a solution to delete records with relationships? I always encounter DB constraint failures. My schema is as follows: model Quiz {
id String @id @default(cuid())
title String
items QuizItem[]
// ...
}
model QuizItem {
id String @id @default(cuid())
quiz Quiz @relation(onDelete: CASCADE)
// ...
} Unfortunately, even when I try to delete each |
@kripod I think your relation is the wrong way around. You should put the |
Is there any update on this? This is currently the one big feature that is keeping me from moving some of my projects to Prisma2. |
We will work on this once we focus on Prisma Migrate (formerly Lift). Right now we are focusing on Prisma Client (formerly Photon). Migrate will be our next focus. |
Hopefully this feature can be prioritized, it's quite a limitation for me 😕 |
Hey @AlexVilchis, while cascading deletes aren't supported by Prisma Migrate, you can still use them with Prisma by configuring them manually in the DB. We have a guide for that here (note that this guide is in the new docs which are still WIP, except pretty much all links to be broken and UX currently also isn't great – will improve over the next few days 🙂 ) |
Great, I was looking for something like this. Thank you |
@nikolasburk the link to the guide is broken. Do you have it in any other form or a working link somewhere? I'm also looking for that. Would be a great workaround. Thanks |
I updated the link in @nikolasburk 's post to the new URL @somonek: https://prisma2.netlify.com/guides/database-workflows/cascading-deletes/postgresql |
Looking forward to see CASCADE feature . It's very important feature for any project ^^ |
waiting for this too |
Very important feature indeed! |
Same, I appreciate all the work but I'm currently migrating a project to Prisma2 and was shocked to find this hadn't yet been carried over from Prisma1, seems pretty fundamental for most nontrivial use cases. |
I just want to quickly mention that while cascading deletes are not natively supported by Prisma, you can use @AhmedElywa's awesome library as a workaround that brings you cascading deletes to Prisma already today: https://paljs.com/plugins/delete |
For the client implementation, the WIP branch with changes in ME/IE is in prisma/prisma-engines#1947 |
Instructions on how to use this, and a place to give feedback: #7816 |
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 |
The behaviour for cascading deletes is specified here.
The text was updated successfully, but these errors were encountered: