'How Do I Resolve This Prisma relationship schema error
model Match {
id String @id @unique @default(cuid())
name String
description String
player1 User @relation( fields: [player1Id], references: [id])
player1Id String
player2 User @relation( fields: [player2Id], references: [id])
player2Id String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
leagueId String
}
model User {
id String @id @unique @default(uuid())
email String @unique
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
matches Match[]
}
Getting following error
Error: Schema parsing
error: Error validating model "Match": Ambiguous relation detected. The fields `player1` and `player2` in model `Match` both refer to `User`. Please provide different relation names for them by adding `@relation(<name>).
--> schema.prisma:85
|
84 | description String
85 | player1 User @relation(fields: [player1Id], references: [id])
86 | player1Id String
|
want to keep track of all of the matches the user plays, each match has two players (Users)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
