Skip to content

@@unique on polymorphic models #1758

@SinPP

Description

@SinPP

Description and expected behavior
I am trying to use polymorphic models. I have a base model and a model which extends the base model. I want to create a unique constraint on the extended model which includes a combination of the base model and the extend model. It fails with an error telling me that the field is not found on the extended model.

Screenshots
image

Environment (please complete the following information):

  • ZenStack version: ^2.6.2
  • Prisma version: ^5.20.0
  • Database type: Postgresql

Additional context
Error: Error validating model "Store": The unique index definition refers to the unknown fields: organizationId.

model Content {
    contentType String

    organization   Organization @relation("OrganizationContents", fields: [organizationId], references: [id])
    organizationId String       @db.Uuid

    @@delegate(contentType)
}
model Store extends Content {
    name      String

    @@unique([organizationId, name])
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions