Cascade onDelete when not using FK relations
Is there a way to add a cascade on delete when declaring relations without FK ? For planetscale for example ?
6 Replies
For Planetscale I found this discussion: https://github.com/planetscale/discussion/discussions/74
GitHub
How do I maintain referential integrity? · planetscale discussion ·...
There are no foreign keys, so how do I relate data: Without duplicating data Making sure that every reference still exists Etc What is the alternative for there being no foreign keys?
Thanks very useful!
That's actually why I don't like planetscale. I love me some referential integrity.
The answer just dismisses
on delete cascade
like nobody should do it.
But what if that's actually the behavior I need in my application. I want Sql to handle the case where I want to delete an user and everything that has to do with it. I don't want to think about it.so if we're using planetscale, the only option we have is to manually retrieve everything and delete it? (i.e. if we would like to delete a user, we have to manually retrieve all blog posts, all comments for the post, and delete them all?)
Announcing foreign key constraints support — PlanetScale
You can now use foreign key constraints in PlanetScale databases.
looks like they announced support for this