Skip to content

Breaking migration: select({ type: 'enum' }) not supported — Prisma enum types dropped, all become String #349

@borisno2

Description

@borisno2

Summary

OpenSaaS Stack does not support the type: 'enum' option on select() fields. In Keystone 6, this option caused the Prisma schema generator to emit proper PostgreSQL enum types and reference them in the column definition. Without this support, all select fields emit String columns, which is a breaking schema change when migrating from Keystone 6.

Keystone 6 Behaviour

direction: select({
  type: 'enum',
  options: [
    { label: 'Inbound', value: 'INBOUND' },
    { label: 'Outbound', value: 'OUTBOUND' },
  ],
  validation: { isRequired: true },
  db: { isNullable: false },
})

Produced in schema.prisma:

direction TextMessageDirectionType

enum TextMessageDirectionType {
  INBOUND
  OUTBOUND
  @@schema("public")
}

OpenSaaS Stack Behaviour

The type: 'enum' option is silently ignored (or not accepted). The same field config produces:

direction String

Impact on Migration

When migrating a live Keystone 6 database to OpenSaaS Stack, the generated Prisma migration will attempt to alter the column type from the PostgreSQL enum type to text/varchar. This requires:

  1. An explicit ALTER TABLE ... ALTER COLUMN ... TYPE text USING ...::text migration
  2. Dropping the enum type from the database
  3. This can fail or require manual intervention if there are foreign key constraints or other dependencies

In this project, the affected models and fields are:

Model Field Keystone 6 Enum Type
TextMessage direction TextMessageDirectionType
TextMessage channel TextMessageChannelType
TextMessage status TextMessageStatusType
TextMessage callStatus TextMessageCallStatusType
VoiceSession direction VoiceSessionDirectionType
VoiceSession status VoiceSessionStatusType
Conversation status ConversationStatusType

Requested Behaviour

Either:

  1. Add type: 'enum' support to select() fields so the Prisma schema emits proper enum types, or
  2. Document the migration path clearly: what SQL migration steps are required to safely convert enum columns to text when migrating from Keystone 6, and whether prisma migrate handles this automatically or requires manual SQL

Additional Context

  • Losing enum types removes database-level validation that prevents invalid values from being stored directly via SQL
  • The silent drop of type: 'enum' means users can easily miss this breaking change during migration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions