CLI workflow
The day-to-day loop on the command line, from changing the model to running an approved ALTER plan.
Every command takes --project <dir> (default: the current directory) and --json to print one JSON object instead of text. Exit code 1 means the command found something to fix.
The loop
- Change the model. Edit through
databee changeset apply <file|->(see changesets and undo), through Studio, or through an agent over MCP. Hand-editing the JSON files also works;validatewill tell you if you broke something, and you should keep the IDs. - Check it.
databee validate,databee lint, both with--fixfor safe corrections. - Look at it.
databee visualize render, or--view diffto see the change against a snapshot. - Generate from it.
databee generate ddl,generate dbml,generate code --lang rust|typescript|python|csharp. See Code generation. - Plan the change for a database. Below.
Snapshots and ALTER plans
A snapshot is an immutable copy of the model files, the starting point for diffs and plans:
databee snapshot before
# ... change the model ...
databee generate alter --name add-placed-at
databee plan show add-placed-at
generate alter compares a snapshot (--from, default the newest) with another one (--to, default the current model) and writes plans/<name>.json and plans/<name>.sql. The plan is built from lock-friendly steps (concurrent index creation, NOT VALID followed by VALIDATE) and every step is marked: the lock it takes, and whether it is destructive, rewrites the table or needs a backfill. plan show lists the steps, the risks and the plan hash. If a column was renamed rather than replaced, --rename old=new confirms it. ALTER plans exist for PostgreSQL only.
Plan `add-placed-at`
hash: c3db6b33ae26a78e1797802f2b0a89624f63277fe51f494562eba4c8c8bb70c4
from: snapshot:before
to: current
status: not approved
steps: 2
1. ALTER TABLE "shop"."order" ADD COLUMN "placed_at" timestamp with time zone DEFAULT now() NOT NULL
[lock: ACCESS EXCLUSIVE]
2. CREATE INDEX CONCURRENTLY "order_customer_id_idx" ON "shop"."order" ("customer_id")
[outside a transaction; lock: SHARE UPDATE EXCLUSIVE]
note: an interrupted build leaves an invalid index that is dropped before a retry
[OK] No destructive or table-rewriting steps
Human output is coloured in a terminal (verdict symbols, warnings, destructive flags). --color always|never overrides that, and NO_COLOR is honoured in auto mode.
Approve and apply
databee plan approve add-placed-at # needs a terminal
databee plan apply add-placed-at --connection shop
plan approve records a human approval for the plan’s current hash. It needs an interactive terminal and has no --yes flag. plan apply refuses a plan without an approval for its current hash, checks that the database still matches the plan’s source model, runs the steps, continues an interrupted run after the last completed step, and compares the database with the target model at the end. Details in Safety.
Other commands
| Command | Purpose |
|---|---|
databee inspect |
Summary of the project and its diagnostics |
databee revision |
The revision a changeset must be based on |
databee undo [--dry-run] |
Take the last changeset back |
databee import dbml <file> |
Read DBML into an empty project |
databee export <profile> |
Data and schema files, see Exports and test data |
databee transform, analyze, migrate |
See Migrations and transformation |
databee studio [path] |
Open the project in Studio |