Skip to content

Abstract model with access policy used in the imported schema cause error #1186

@jiashengguo

Description

@jiashengguo

ZenStack will give

⌛️ ZenStack CLI v2.0.0-alpha.6, running plugins
✔ Generating Prisma schema
✖ Generating PrismaClient enhancer
Prisma Enhancer: Unresolved ReferenceExpr

schema.zmodel

import "prisma/schema"

prisma/schema.zmodel

generator client {
    provider        = "prisma-client-js"
    binaryTargets   = ["native"]
    previewFeatures = ["postgresqlExtensions"]
}

datasource db {
    provider   = "postgresql"
    extensions = [citext]

    url       = env("DATABASE_URL")
}
enum UserRole {
    USER
    ADMIN
}


model User {
    id String @id @default(uuid())
    role UserRole @default(USER) @deny('read,update', auth().role != ADMIN)
    post Post[]
}

abstract model Base {
    id String @id @default(uuid())
    userId String
    user User @relation(fields: [userId], references: [id])

    @@allow('create', userId == auth().id)
    @@allow('update', userId == auth().id && future().userId == auth().id)

    @@allow('all', auth().role == ADMIN)
}


model Post extends Base {
    description String
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions