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
In Prisma 4.6.0, changing onDelete: SetNull
to Cascade
results in recreating foreign key
#16228
Comments
Can you check if this is still happening with 4.6.1 that went out a short time ago? We tightened our validation rules around referential actions in 4.6.0: If dropping and recreating vs. altering is correct I am trying to figure out internally. |
Hi @jameyhart, thanks for opening this issue. The SQL is correct, we are not aware of another way to change the referential action on PostgreSQL unfortunately, a drop and create must happen. The validation error you see, like @janpio mentioned, is a recent change added in #14673 which is not yet documented (we will do that soon).
Let us know if something is unclear or if this is a problem for you. |
Hi both, thanks for the speedy reply! So, upgrading to v4.6.1 fixed the bug we were experiecing with enums. Also, yes - everything you said makes sense. I've discussed with the team and we're happy for you to close this issue and we'll review both our Prisma versions and our database models going forward. Thanks so much! |
Great news! Thanks for the speedy reply as well, we're very happy this helped your team 👍🏼 |
Thanks for the feedback, perfect outcome here then. Bug fixed in patch, our validation did its job, and your issue helped us to confirm all of this. Enjoy your weekend! |
4.6.1 also fixed the enum error for us. 4.6.0 caused the problem. |
Discussed in #16223
Originally posted by jameyhart November 10, 2022
@janpio After upgrading to 4.6.0, we started reciving the following error when migrating our database:
To rectify this, we changed the
onDelete
fromSetNull
toCascade
but it then cerates a new migration that drops the foreign key and recreates it.Is this the expected behaviour?
Our current database model:
The output from the new migration:
The text was updated successfully, but these errors were encountered: