merge, rebase, and reconcile¶
Manage branch merge reconciliation for migration histories.
merge¶
Reconciles divergent migration histories after a branch merge.
Usage¶
$ dbwarden merge --database primary
$ dbwarden merge --database primary --force
$ dbwarden merge --database primary --rename-column users.username=users.handle
Options¶
--database,-d: Target database name--rename-column: Column rename to confirm (format:table.old=new)--rename-table: Table rename to confirm (format:old=new)--force,-f: Force marking hand-edited migrations--commit: Create a git commit with the changes--json: Output results as JSON--verbose,-v: Enable verbose logging
What it does¶
- Checks preconditions (clean working tree, no conflict markers)
- Resolves merge-base state from git
- Rebuilds current model state from merged models
- Computes reconciliation diff using the snapshot diff pipeline
- Probes persistent environments (works with all database types)
- Generates reconciliation migration with actual SQL
- Marks branch migrations as superseded
- Reports results
- Optionally creates a git commit with
--commit
Example¶
$ dbwarden merge --database primary
Merge reconciliation summary
Merge base: 0004 (state checksum 9f2c...)
Superseded: 0005_add_profile.sql, 0005_extend_billing.sql
Reconciliation: 0006_merge_feature_a_feature_b.sql
Environments: staging: clean, production: clean
Next steps: commit; developers on feature branches: dbwarden rebase
Merge reconciliation complete.
rebase¶
Recovers a disposable environment after a merge.
Usage¶
$ dbwarden rebase --database local
$ dbwarden rebase --database local --yes
$ dbwarden rebase --database local --check
Options¶
--database,-d: Target database name--yes,-y: Skip confirmation prompts--force,-f: Force operation even against persistent environments--check: Only check what would happen, don't make changes--verbose,-v: Enable verbose logging
What it does¶
- Reads local applied migrations
- Identifies superseded versions
- Rolls back to merge-base using superseded files (preferred) or resets (fallback)
- Re-applies runnable chain
- Verifies convergence
Note: The rebase command can read rollback SQL from superseded files, which are normally excluded from the rollback chain.
Example¶
$ dbwarden rebase --database local
Found 2 superseded migration(s) applied: 0005, 0006
Rolling back to merge-base version 0004...
Rolled back to version 0004
Re-applying migrations...
Migrations re-applied successfully.
Verifying convergence...
Convergence verified.
Rebase complete.
reconcile¶
Recovers a persistent environment after a dirty merge.
Usage¶
Options¶
environment: Environment name to reconcile (required)--database,-d: Target database name--rename-column: Column rename to confirm--dry-run: Only show what would happen--verbose,-v: Enable verbose logging
What it does¶
- Snapshots live environment
- Diffs against merged models
- Generates environment-specific reconciliation
- Applies with lock discipline
- Updates merge record
Example¶
$ dbwarden reconcile --environment staging
Reconciling environment: staging
Environment: staging (persistent: true)
Snapshotting live environment...
Computing diff against merged models...
Generating environment-specific reconciliation...
Applying reconciliation...
Updating merge record...
Reconciliation for environment 'staging' complete.
See also¶
- Merge Handling: Complete merge handling guide
- Migration Locking: How migrations are locked
- Status: Check migration status