zenstackhq/zenstack

Delegate & Index & Abstract model

Closed this issue · 1 comments

eqqe commented

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 commented

Fixed in 2.8.0