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

Update docs with cascading deletes from Prisma #546

Open
arslancharyev31 opened this issue Aug 31, 2021 · 5 comments
Open

Update docs with cascading deletes from Prisma #546

arslancharyev31 opened this issue Aug 31, 2021 · 5 comments

Comments

@arslancharyev31
Copy link

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 states that:

Prisma does not yet support "cascading deletes".

However since version 2.26.0 Prisma does support cascading deletes via Referential actions. 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.

@flybayer
Copy link
Member

flybayer commented Sep 1, 2021

We are getting close to 1.0, so let's leave it as is until it's stable. But we can go ahead and add a note mentioning the preview feature!

@arslancharyev31
Copy link
Author

arslancharyev31 commented Sep 1, 2021

I understand. But what about the usage of alpha version of React and its experimental Suspense feature? Are they going to make it into the 1.0? I am just trying to understand the rationale for including some experimental features, but not others.

@flybayer
Copy link
Member

@arslancharyev31 sorry for the delay here! Since we are nearing 1.0, we are trying to minimize experimental things. React alpha is the only pre-stable thing we have now. React alpha is being used at facebook and the suspense feature we are using is extremely stable (within alpha). Does this make sense?

@yume-chan
Copy link

Blitz now defaults to Prisma 3 (blitz-js/blitz#2731) and Referential actions has been out of preview.

Mandatory relations (the Token model) now defaults to ON DELETE RESTRICT, so @relation(..., onDelete: Cascade) is required for cascade deletes.

There are also several places not updated to say Prisma 3

By default, Blitz uses Prisma 2 which is a strongly typed database client.
> Prisma 2 is not required for Blitz. You can use anything you want, such

You can use any database you want. Prisma 2 is the default database client, but

@JuanM04
Copy link
Contributor

JuanM04 commented Nov 14, 2021

Referential actions has been out of preview

Maybe we can change the Tutorial — instead of adding a new DELETE, we can make the users update the Prisma schema.

There are also several places not updated to say Prisma 3

Fixed by a9dc52e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants