Skip to main content

Enums

Enums define a fixed set of valid values for a field — like a status, tier, or category type.

Creating enums via chat

"Create a carbon_tier enum with values: A, B, C, D" "Add an order_status enum: draft, confirmed, shipped, received, cancelled" "Create a customer_tier enum with: enterprise, mid_market, smb"

Using enums on fields

After creating an enum, reference it when defining fields:

"Add a carbon_tier field to suppliers of type carbon_tier, default 'C', not null" "Add a status field to purchase_orders of type order_status"

Managing enum values

Add a value:

"Add 'on_hold' to the order_status enum"

Rename a value:

"Rename 'smb' to 'small_business' in the customer_tier enum"

Remove a value:

"Remove 'draft' from the order_status enum"

How enums export

In PostgreSQL export, enums become CREATE TYPE:

CREATE TYPE carbon_tier AS ENUM ('A', 'B', 'C', 'D');

In MySQL export, enums become inline column definitions:

carbon_tier ENUM('A', 'B', 'C', 'D') NOT NULL DEFAULT 'C'

Best practices

  • Use enums for fixed, small sets — status fields, tier types, categories
  • Avoid enums for large or frequently changing sets — use a lookup table instead
  • Use descriptive values'confirmed' is clearer than '2'
  • Consider NULL — decide whether NULL is a valid enum value for optional fields