Possibility to create two entities in one transaction with cross- and not nullable relations. #3502
Labels
kind/feature
A request for a new feature.
team/client
Issue for team Client.
team/schema
Issue for team Schema.
topic: client api
Problem
Let's say we have
User
andOrganisation
. EachUser
is a member of anOrganisation
and eachOrganisation
has an owner. Both relations are not nullable.This could be implemented like with this
schema.prisma
:How to create a new pair of
User
andOrganisation
withprisma
?As we realized #3483, this could not be made by the nested writes.
Because of "NOT NULL" constraints for both relations, this issue looks similar to the chicken-egg problem.
How the solution might be look like?
Why the solution doesn't work now?
This is how it's being overcome in "raw" Postgres:
prisma
doesn't allow us to adjust this behavior.prisma
), the code still doesn't work, becauseprisma
checking the existence of foreign key before insertion. As a result –AssertionError
withExpected a valid parent ID to be present for a nested connect on a one-to-many relation
.Suggested solution
The text was updated successfully, but these errors were encountered: