I'm trying to make two 1:1 relations in one model in Prisma ORM, but got following error:
Error validating model "Person": Ambiguous relation detected. The fields
placeOfBirth
andplaceOfDeath
in modelPerson
both refer toPlace
. Please provide different relation names for them by adding@relation(<name>)
.
My prisma schema:
model Place {
id Int @id @default(autoincrement())
name String
persons Person[]
}
model Person {
id Int @id @default(autoincrement())
name String
placeOfBirthId Int
placeOfDeathId Int
👉 placeOfBirth Place @relation(fields: [placeOfBirthId], references: [id])
placeOfDeath Place @relation(fields: [placeOfDeathId], references: [id])
}
Totally don't get it.