Document SetNull
validation introduced in [email protected]
#4035
Labels
docs
Documentation creation, updates or corrections
size: S
more than one hour, up to one day
topic: referential actions
Milestone
In the "Referential Actions" page, we should mention that, starting from
[email protected]
, defining a Prisma schema with aSetNull
referential action referencing a non-nullable field is no longer valid.Consider the following Prisma models:
The
@relation
inProfile
is not valid anymore, as the referenced field (user_id
) has a non-nullable type (Int
).We have decided to add this new Prisma validation as, with the scenario above, all databases would fail with a validation error at the database level (which would result in a Prisma migration error). The only exception is Postgres, which accepts
SET NULL
referential actions, but would fail at runtime once such action is triggered by a change in a referenced row.The new validation error message is:
Here's an example of a valid Prisma schema using
SetNull
appropriately:Please check out the internal notion for additional context.
The text was updated successfully, but these errors were encountered: