Skip to content

Delegate & Index & Abstract model #1786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eqqe opened this issue Oct 17, 2024 · 1 comment
Closed

Delegate & Index & Abstract model #1786

eqqe opened this issue Oct 17, 2024 · 1 comment
Milestone

Comments

@eqqe
Copy link

eqqe commented Oct 17, 2024

Cannot put index in abstract model used by delegate model.

See https://github.com/eqqe/reprod-zenstack for reproduction.

{21BBF70C-F217-40AF-99C4-191A8CA936A0}

{DB558FE3-3B7D-4271-B7CB-33DE5C524DF4}

model User {
    id       String @id @default(cuid())
    email    String @unique @email @length(6, 32)
    password String @password @omit
    contents    Content[]

    // everybody can signup
    @@allow('create', true)

    // full access by self
    @@allow('all', auth() == this)
}

abstract model BaseContent {
  published Boolean @default(false)

  @@index([published])
}

model Content extends BaseContent {
    id       String @id @default(cuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  owner User @relation(fields: [ownerId], references: [id])
  ownerId String
  contentType String

  @@delegate(contentType)
}

model Post extends Content {
  title String
}

model Video extends Content {
  name String
  duration Int
}
⌛️ ZenStack CLI v2.7.0, running plugins
Prisma schema loaded from prisma\schema.prisma
Error: Prisma schema validation - (get-dmmf wasm)
Error code: P1012
error: Error validating model "Post": The index definition refers to the unknown fields: published.
  -->  prisma\schema.prisma:48
   |
47 |
48 |     @@index([published])
   |
error: Error validating model "Video": The index definition refers to the unknown fields: published.
  -->  prisma\schema.prisma:57
   |
56 |
57 |     @@index([published])
   |

Validation Error Count: 2
[Context: getDmmf]

Prisma CLI Version : 5.21.0
✖ Generating Prisma schema
Prisma: Failed to run "prisma generate"```
@ymc9
Copy link
Member

ymc9 commented Nov 6, 2024

Fixed in 2.8.0

@ymc9 ymc9 closed this as completed Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants