OnUpdate default referential Integrity action while using Prisma to handle referential Integrity
See original GitHub issueIntro
it is mentioned in the docs that the default referential integrity actions are these here
but it is also stated in the docs that while using Prisma to handle referential integrity that the available actions are
It is not clearly mentioned in the docs that you should manually set the onUpdate
to noAction
Problem
enabling the preview feature referentialIntegrity
and attempting to update a record that has relation lead me to this error (creating and deleting records works fine)
Message:
Invalid `prisma.institution.update()` invocation:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Server(ServerError { code: 1105, message: "symbol db.Institution.id not found", state: "HY000" })) })
Query:
prisma.institution.update(
{
where: {
id: 44,
},
data: {
firstName: "Random",
},
select: {
id: true,
firstName: true,
},
}
)
Solution
setting onUpdate
to noAction
resolved this error. I would like to propose to either set the default action while using referentialIntegrity
for update operation to noAction
(since this is the only available option at this time) or at least mention this explicitly in the documentation
Notes
I should also note I was using Prisma combined with Planetscale, i don’t know if this is relevant but i’ll just leave it here
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:6 (4 by maintainers)
Top GitHub Comments
Apologies, but I only ran
prisma migrate dev --name <name>
, (which I believe runsgenerate
regardless of pending migrations or not). I think it might have mixed with the issue that I had previously with running prisma while usingpnpm
in my repo, which didn’t update the client properly unless I did a reinstall of the client when doing eithermigrate
orgenerate
. But it looks like that is no longer an issue either (don’t know which version fixed that for me, or if it was apnpm
issue).I cannot reproduce my generate issue anymore. It’s just the
onDelete
andonUpdate
that does not seem to have sane defaults forreferentialIntegrity
, as you have already mentioned.We think this is only a docs issue - so closing and creating a new one there.