schemabrain diff
Compares an on-disk project tree against the local store. Reports three kinds of drift per resource type:
- only-on-disk — file exists, no corresponding store row.
- only-in-store — store row exists, no corresponding file.
- value-mismatch — both exist; the YAML body differs.
export-all ↔ apply exactly. Trust-signal fields are deliberately excluded from comparison — they’re not part of the YAML grammar.
schemabrain apply.
Flags
| Argument / Flag | Default | Purpose |
|---|---|---|
project_dir (positional) | ./schemabrain | Path to the project tree. |
--source URL | (none) | Source URL the YAMLs attach to. |
--url-env VARNAME | (none) | Env var holding the source URL. Preferred. |
--store-path PATH | ./schemabrain.db | Path to the local SQLite store. |
Exit codes (CI-friendly)
| Code | Meaning |
|---|---|
0 | In-sync. Tree matches store. |
1 | Drift detected. The output lists exactly what differs. |
2 | Operational error — missing dir, malformed YAML, unreachable store, etc. |
diff safe in CI gates:
Examples
Pre-deploy gate
Apply only if clean
Investigate drift before resolving
What diff does not check
- Source schema drift (added or removed columns in Postgres) — use
schemabrain checkfor that. - Trust-signal drift (
origin,inference_method,validation_state) — those fields are deliberately not part of the YAML grammar, so they would always read as drift if compared. Useschemabrain inspectto view trust signals. - dbt-owned resources — resources with
origin='dbt'are still compared; if you want to skip them, filter the project tree before diffing.
Related
schemabrain apply
Resolve drift by applying the on-disk version to the store.
schemabrain check
Source-schema drift (the orthogonal question).
schemabrain inspect
Browse trust signals that
diff deliberately ignores.schemabrain entities export-all
Re-export to disk to resolve
only-in-store drift.