Overview & Installation
dbmt is the native command-line interface for dbmigrate. It is bundled directly with the desktop application for macOS and Windows, sharing the same local encrypted configuration store, connection definitions, and environment protection rules.
# Verify your installation and version$ dbmt --version
dbmt version 1.0.0 (darwin/arm64)
Configure Your dbmt Command
Build production-safe CLI commands for local terminals, automated cron jobs, or CI/CD pipelines.
dbmt compare --profile staging-to-prod --engine postgres Expected Exit Codes for dbmt compare
- Exit 0Clean: Schemas match perfectly with zero drift.
- Exit 1Drift Detected: Schema differences found. Review output diff.
- Exit 2Connection Error: Failed to reach or authenticate with database.
Working with Profiles
A profile contains your source connection, target connection, selected object filters, and environment protection rules. You can create profiles visually in the desktop application and execute them headlessly with dbmt.
# List all configured profiles stored locally$ dbmt profiles list
NAME ENGINE SOURCE TARGET PROTECTION
staging-to-prod PostgreSQL dev_db prod_db High
sandbox-refresh MySQL prod_replica sandbox_db Medium
dbmt compare
Inspects source and target schemas for drift according to the profile's filter rules. Outputs a human-readable diff summary and returns standard exit codes for automated testing.
Comparing [dev_db] → [prod_db] (PostgreSQL 16)
[+] 1 table modified: app.orders (+ status varchar(32))
[+] 1 index added: idx_orders_status
[=] 28 tables unchanged
Drift detected: 2 object differences found.
dbmt plan
Generates ordered, dependency-resolved DDL synchronization SQL without executing it against the target database. Use --out to save the script for auditing, code review, or storage in pull requests.
Plan written to ./migration-plan.sql (2 statements, ordered by FK dependency).
dbmt apply
Executes the planned migration against the target database. Respects the target's configured environment protection gates. High-protection targets require dry runs to pass before real execution is permitted.
# Perform a dry run rehearsal first$ dbmt apply --profile staging-to-prod --dry-run
✓ Dry run succeeded: Target schema valid. No constraint violations.
# Apply migration with target confirmation$ dbmt apply --profile staging-to-prod --confirm-target prod_db
Applying 2 changes to [prod_db]...
✓ 2/2 changes applied successfully. Snapshot saved to run history.
Protection Gate Notice: In high-protection environments, dbmt apply requires the --confirm-target <dbname> flag to prevent accidental execution against production.
Deterministic Exit Codes
dbmt returns consistent Unix exit codes, making it simple to write shell scripts, Git pre-push hooks, and automated CI quality gates:
- 0 (Success): Operation succeeded. For
compare, means source and target schemas are in sync with zero drift. - 1 (Drift Detected): In
compare, indicates differences were detected between source and target. - 2 (Validation / Gate Failure): Pre-execution dry run failed, or environment protection requirements were not met.
- 3 (Execution Error): Connection timeout, authentication failure, or SQL execution exception.
GitHub Actions / CI Example
Fail a pull request build if unexpected schema drift is detected between your staging branch and the reference database:
# .github/workflows/schema-drift.ymlname: Check Schema Drift
on: [pull_request]
jobs:
verify:
runs-on: [self-hosted, macOS]
steps:
- uses: actions/checkout@v4
- name: Run dbmt drift check
run: |
dbmt compare --profile ci-staging-check || exit 1