Skip to main content

schemabrain check

Probes the live source Postgres and compares its current schema to the snapshot in the local store. Surfaces three kinds of drift:
  • Tables that were indexed but no longer exist.
  • Columns that were indexed but no longer exist.
  • Type / nullability changes on existing columns.
This is the source-side drift check. For drift between the store and an on-disk YAML project tree, use schemabrain diff.
schemabrain check --url-env DATABASE_URL --store-path ./schemabrain.db

Flags

FlagDefaultPurpose
--source URL(none)Source URL. Deprecated when the URL contains a password. One of --source / --url-env is required.
--url-env VARNAME(none)Env var holding the source URL. Preferred.
--store-path PATH./schemabrain.dbPath to the local SQLite store.
--json(off)Emit JSON to stdout instead of the rich-rendered report to stderr. Pipe-friendly for CI / monitoring.

When to run it

  • After any database migration.
  • On a schedule, paired with an alert when the JSON output reports non-empty drift.
  • Before running schemabrain serve in a long-lived environment.
After check reports drift, re-run schemabrain index --url-env DATABASE_URL --store-path ./schemabrain.db to refresh the snapshot. Indexing is idempotent and only re-enriches changed columns.

Examples

Default human report

schemabrain check --url-env DATABASE_URL --store-path ./schemabrain.db

CI-friendly JSON

schemabrain check --url-env DATABASE_URL --store-path ./schemabrain.db --json > drift.json

Refresh after detecting drift

schemabrain check --url-env DATABASE_URL --store-path ./schemabrain.db || \
  schemabrain index --url-env DATABASE_URL --store-path ./schemabrain.db

schemabrain index

Refresh the snapshot after check reports drift.

schemabrain diff

The orthogonal drift question — project tree vs store.

schemabrain doctor

Broader health check covering host config + store.

schemabrain inspect

Browse the indexed schema without re-probing the source.