DSL syntax

Schema Forge schemas are written in .sf files. By default the main file is schemaforge/schema.sf.

Comments

Use # for line comments.

# SchemaForge schema definition
# table users { ... }

Tables

Declare a table with table <name>{ ... }. Column definitions go inside the braces, one per line.

table users {
  id uuid
  email varchar
  name text
}

Columns

Each column is name type [modifiers]. Common types include:

  • uuid, varchar, text
  • boolean, integer, bigint
  • timestamptz

Modifiers

  • pk — primary key
  • unique — unique constraint
  • not null / nullable — nullability
  • default <expr> — default value (e.g. now())
  • fk <table>.<column> — foreign key

Example

# SchemaForge schema definition

table users {
  id uuid pk
  email varchar unique not null
  name text not null
  created_at timestamptz default now()
}

table posts {
  id uuid pk
  user_id uuid fk users.id not null
  title varchar not null
  content text
  published boolean default false
  created_at timestamptz default now()
}

Invalid syntax

The parser will report errors for invalid DSL: unclosed braces, unknown column types, or malformed foreign keys (e.g. fk table without .column). Run schema-forge generate or schema-forge diff to validate; see the CLI commands doc.