Skip to content

Adding @@ignore to a model that references an enum fails to generate enhanced client #1835

Closed
@wmartins

Description

@wmartins

Description and expected behavior

Ignoring a model with @@ignore causes the enhanced client generation to fail if said model references an enum.

For example, this schema.zmodel:

datasource db {
  provider          = "postgresql"
  url               = env("DATABASE_URL")
}

generator js {
  provider = "prisma-client-js"
  output   = "../node_modules/@prisma-app/client"
}

enum Enum {
    SOME_VALUE
    ANOTHER_VALUE
}

model Model {
    id String @id @default(cuid())
    value Enum
    @@ignore
}

model AnotherModel {
    id String @id @default(cuid())
}

Causes the following error when running zenstack generate:

⌛️ ZenStack CLI v2.8.0, running plugins
✔ Generating Prisma schema
✔ Generating PrismaClient enhancer
Error compiling generated code:
node_modules/.zenstack/policy.ts:5:10 - error TS2305: Module '"../@prisma-app/client"' has no exported member 'Enum'.

5 import { Enum } from "../@prisma-app/client";
           ~~~~

: Error compiling generated code
error: "zenstack" exited with code 1

Screenshots

N/A.

Environment (please complete the following information):

  • ZenStack version: 2.8.0
  • Prisma version: 5.18.0
  • Database type: PostgreSQL

Additional context

We're currently investigating a better process for dropping tables/columns with no downtime. Part of this process uses @ignore/@@ignore to first remove the table/column reference from the Prisma client, and then, in a subsquent work, we actually drop the table/column. While doing that, we stumbled upon this issue where, if we ignore a model with an enum, we can't generate the enhanced client due to the compilation error sent up there.

Prisma doesn't seem to support @ignore for enums (https://www.prisma.io/docs/orm/prisma-schema/data-model/models#defining-enums), so we weren't able to explore that.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions