Models
A model is a table definition: name, fields, types, and attrs. Put the file under data/ and the loader picks it up. The migration generator turns it into SQL. The runtime exposes a CRUD surface at main_db.<name>.<method>(...).
Declare a model
data/user.rat
Each body line is field_name type with optional bracketed attrs. Types map to SQL: text, number, date, bool. Attrs like [pk], [unique], and [length: 256] annotate constraints.
> model [user]
id text [pk]
email text [unique]
name text [length: 128]
created_at date Cross-file constraints
data/user_extras.rat
A > contraint [user] block (the canonical typo; both spellings work) adds extra attrs to a model declared elsewhere. Use it when one team owns the schema and another owns indexing.
# data/user_extras.rat
> contraint [user]
email: [encrypted]
name: [index] Check what the loader found
rat db status
The CLI lists every model the loader found, with its fields and attrs. Run it after edits to confirm what the loader sees. It catches a typo without a round-trip through migrations.
rat db status