Skip to content

The generated prisma failed to compile if both the relation field of entity and it's base type exsit in one model #1100

@jiashengguo

Description

@jiashengguo

The below schema passes the ZenStack CLI, but the generated Prisma schema fails validation:

Error: Prisma schema validation - (get-dmmf wasm)
Error code: P1012
error: Error validating field `posts` in model `User`: The relation field `posts` on model `User` is missing an opposite relation field on the model `Post`. Either run `prisma format` or add it manually.
model User {
  id String @id @default(cuid())
  name String?
  content Content[]
  post Post[]
}
model Content {
  id String @id @default(cuid())
  published Boolean @default(false)
  contentType String
  @@delegate(contentType)

  user User @relation(fields: [userId], references: [id])
  userId String
}

model Post extends Content {
  title String
}
model Image extends Content {
  url String
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions