In the previous prisma version you could add an on...
# orm-help
o
In the previous prisma version you could add an onDelete on a @relation. How can you do that in prisma2? It is impossible now to delete a model that is attached to something.
j
Either you add the ondelete in the database itself, or manually perform the delete cascade in your resolvers
Or delete actions
a
@Oscar you can use prisma docs workaround to add this function into your db https://www.prisma.io/docs/guides/database-workflows/cascading-deletes/postgresql or use my tool to auto delete on your resolver https://github.com/AhmedElywa/prisma-tools/tree/master/packages/delete
o
Wouldn't adding it manually be hard to do because you would want prisma to maintain the database or can you create a sql migration with custom sql?
@Ahmed The tool you created seems promising!
👍 2
a
You can use it with my other tools
👍 1
r
Hey Oscar 👋 Currently it isn't supported via the Prisma schema syntax so as a workaround, you would have to add it via SQL statements. You can also track the spec here for more info.