scribase schema
Works with Scribase schema files — the typed model-definition language that compiles to Postgres DDL with RLS policies baked in.
Subcommands
schema compile <file> [--out FILE]
Compiles a schema file to Postgres SQL. Validates the schema and reports any errors or warnings.
scribase schema compile schema.scribase
scribase schema compile schema.scribase --out schema.sqlWithout --out, the SQL is printed to stdout. With --out, it is written to
the given file.
schema test <file>
Runs the Aegis policy tests embedded in the schema file. Tests are declared inline with the schema and verify RLS policy behavior against synthetic authenticated contexts.
scribase schema test schema.scribaseOutput shows each test, its expected outcome, and pass/fail status. A non-zero exit code means at least one test failed.
Schema file format
A .scribase file defines models (tables) with typed columns, constraints, and
RLS policies in a concise declarative syntax. Example:
model orders {
id uuid primary key default gen_random_uuid()
user_id uuid not null references auth.users
total numeric(12,2) not null check (total > 0)
created_at timestamptz not null default now()
policy "owner can read" on select
using (auth.uid() = user_id)
policy "owner can insert" on insert
with check (auth.uid() = user_id)
}The compiler generates:
CREATE TABLEwith columns and constraintsALTER TABLE ENABLE ROW LEVEL SECURITYCREATE POLICYfor each declared policyGRANTstatements for application roles
Notes
- Run
schema testin CI to catch policy regressions before deployment. schema compilecan be used to preview the SQL before sending it to the server.- The Scribase schema language is a superset of what
scribase importcan read back from an existing database.
See Aegis Policy Compiler for the full policy testing reference.