Skip to content

[bug] migrations fail when views are defined unless generator with previewFeatures = ['views'] is present in the schema (v3) #2376

@alexbatis

Description

@alexbatis

Description and expected behavior

expected behavior: migrations work without adding a generator to the zmodel shema
actual behavior: migrations do not work when views exist in the zmodel schema unless a generator is added

When running migrate with views i get the following error

✔ Generating TypeScript schema
Generation completed successfully in 242ms.

You can now create a ZenStack client with it.
Check documentation: https://zenstack.dev/docs/
Environment variables loaded from .env
Prisma schema loaded from db/zenstack/~schema.prisma
Datasource "db": PostgreSQL database "postgres", schemas "<omitted>" at "<omitted>"


Error: Prisma schema validation - (validate wasm)
Error code: P1012
error: Error validating: View definitions are only available with the `views` preview feature.
  -->  db/zenstack/~schema.prisma:498

adding this to the zmodel schema fixes the error:

generator client {
    provider = ''
    previewFeatures = ['views']
}

however, it creates a warning:

"generator" is not used by ZenStack and should be removed.

Environment:

  • ZenStack version: [3.3.2]
  • Database type: [Postgresql]
  • Node.js/Bun version: [24.12.0]
  • Package manager: [bun]

Additional context
Not sure if related but i am using multiple postgres schemas (@@schema("schema_name")) across my models/views/enums/etc:

datasource db {
    provider = 'postgresql'
    url = env('DATABASE_URL')
    defaultSchema = 'public'
    schemas = [...]
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions