blitz-js / blitz-js/blitzjs.com
Update docs with cascading deletes from Prisma
- Dominant language
- MDX
- Stars
- 188
- Forks
- 316
- PR merge metrics
- No merged PRs in 30d
Description
Good day.
I've been following the Blitz tutorial and so far it has been a great experience. However I noticed some outdated info in the docs that I believe is worth mentioning. The section about [`deleteQuestion` mutation][1] states that:
> Prisma does not yet support "cascading deletes".
However since version [2.26.0][2] Prisma does support cascading deletes via [Referential actions][3]. The caveat is that it is a **Preview feature**. But then again, so is React Suspense, which is used throughout the starter project.
It is worth noting that even without enabling the _Referential actions_ feature, running `blitz generate all/resource/etc.` creates the DB migrations that already have `ON DELETE CASCADE` clause present on the foreign keys. When I looked up the initial DB migration, the _Session_ table had `ON DELETE SET NULL` for the `userId` foreign key, while the _Token_ table had `ON DELETE CASCADE` for the same key. I am not sure if these `ON DELETE` discrepancies are intended and what implications they had when the _Referential actions_ feature is disabled. I still had to add `onDelete: Cascade` clause in all foreign keys defined in `schema.prisma`, even after enabling the feature.
[1]: https://blitzjs.com/docs/tutorial#delete-question-mutation
[2]: https://github.com/prisma/prisma/releases/tag/2.26.0
[3]: https://www.prisma.io/docs/concepts/components/prisma-schema/relations/referential-actions
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.