0

Error validating model "Comment": Ambiguous self relation detected. The fields comment and Comment in model Comment both refer to Comment. If they are part of the same relation add the same relation name for them with @relation(<name>).

model Comment {
 id            Int             @id @default(autoincrement())
 text          String          @db.VarChar
 rating        Int             @default(0)
 createdAt     DateTime        @default(now()) @db.Timestamp(6)
 creatorId     Int
 postId        Int?
 repliedToId   Int?
 user          User            @relation(fields: [creatorId], references: [id])
 post          Post?           @relation(fields: [postId], references: [id])
 comment       Comment?        @relation(fields: [repliedToId], references: [id])
 Comment       Comment[]       @relation("CommentToComment")
 CommentRating CommentRating[]
 }

1 Answers1

0

You just have to add name of the relation against comment attribute like this

...

comment     Comment?  @relation("CommentToComment", fields: [repliedToId], references: [id])
Comment     Comment[] @relation("CommentToComment")

Ahmed Nawaz Khan
  • 1,451
  • 3
  • 20
  • 42