Enums, groups and notes

Write enums, table groups and notes in schema code.

Enums, groups and notes each have a block of their own in schema code. This page shows how to write each one.

Enums

Enum order_status {
  pending
  paid [note: 'Money received']
  shipped
  "on hold"
}

An enum lists its values, one per line. A value can have a note, and a value with spaces goes in double quotes.

A column uses the enum by giving its name as its type, such as status order_status. An enum needs at least one value.

Groups

TableGroup billing {
  invoices
  invoice_lines
  payments
  Note: 'Everything to do with getting paid'
}

A group lists the tables it frames, one per line, and can have a note. A table can be in one group.

Notes

Notes say what names can't. A table, a column, an enum value, a group and the Project can each have one, as shown on these pages.

For a note of several lines, use three single quotes:

Table orders {
  id integer [pk, increment]
  Note: '''
    One row per checkout.
    Rows are never deleted, only cancelled.
  '''
}

A note of its own, outside any table, is a Note block with a name: Note overview { 'Read me first' }. The canvas draws it as a card below the tables, and it can take a colour.

The text of a note of its own can be styled: **bold**, *italic*, `code` and ~~struck~~. See Rename and style text.

On this page