Diff first
Compare two instances before you touch production and catch drift while it is still explainable.
Schema diff and migration SQL
DBDiff compares two databases, highlights structural differences, and generates dialect-aware migration SQL for PostgreSQL, MySQL, and SQL Server from one CLI.
Source
users
id bigint pk
email text unique
name text
created_at timestamptz
Target
users
id bigint pk
email varchar(255) unique
display_name text
created_at timestamptz
updated_at timestamptz
Generated SQL
ALTER TABLE users
RENAME COLUMN name TO display_name;
ALTER TABLE users
ADD COLUMN updated_at timestamptz;
Compare
The practical win is speed of review. Instead of flipping between different tools for inspection and migration output, DBDiff keeps the diff, the dialect, and the generated SQL in one flow.
Compare two instances before you touch production and catch drift while it is still explainable.
Produce migration scripts in SQL, JSON, or table output depending on where the result needs to go next.
Review is the default posture, which makes it easier to trust the tool inside a delivery workflow.
Dialects
The tool is useful precisely because it does not flatten everything to one generic SQL dialect. It keeps the generated statements close to the actual target platform.
`ALTER COLUMN TYPE`, schema-aware introspection, and transaction-friendly flows.
`MODIFY COLUMN` generation and MySQL-specific comparison behavior.
Cross-instance diffing with SQL Server connection support built into the same CLI.
Install
Go install is the cleanest starting point. After that, compare two schemas and inspect the generated SQL before you wire the tool into a wider migration process.
go install github.com/meru143/dbdiff@latest
dbdiff compare postgres://source postgres://target
dbdiff migrate -s postgres://source -t postgres://target -o migration.sql
Output modes:
- sql
- table
- json
- dry-run review first