Skip to content

diff

Show structural differences between SQLAlchemy models and a live database. Read-only: no files are written.

Usage

$ dbwarden diff --database primary
$ dbwarden diff --database primary --out json
$ dbwarden diff --database primary --out sql
$ dbwarden diff --database primary --offline

Options

Option Description
--database, -d Target database name
--out, -o Output format: table (default), json, sql
--offline Use exported model state file instead of live DB snapshot
--verbose, -v Enable verbose logging

Output formats

table (default)

Displays a Rich table with columns: Operation, Table, Target, Severity.

          Schema Diff           
┏━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━┳━━━━━━━━━┓
┃ Operation    ┃ Table ┃ Target ┃ Severity┃
┡━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━╇━━━━━━━━━┩
│ add_column   │ users │ email  │ INFO    │
│ drop_column  │ users │ name   │ WARNING │
└──────────────┴───────┴────────┴─────────┘

json

[
  {"operation": "add_column", "table": "users", "target": "email", "severity": "INFO"},
  {"operation": "drop_column", "table": "users", "target": "name", "severity": "WARNING"}
]

sql

Prints the raw migration SQL that would be generated.

Offline mode

Requires a model state file created by dbwarden export-models:

$ dbwarden export-models --database primary
# Switch to offline machine
$ dbwarden diff --database primary --offline

See also