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 bigserial pk
email text not null
last_seen timestamptz
Target
users
id bigserial pk
email varchar(255) not null
legacy_sessions
id bigserial pk
token text
Generated SQL
ALTER TABLE users ADD COLUMN
last_seen timestamp with time zone NULL;
ALTER TABLE users ALTER COLUMN email
TYPE text USING (email::text);
DROP TABLE IF EXISTS legacy_sessions CASCADE;
Compare
Review faster. 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.
compare and migrate only read the databases. apply asks before it changes one, unless --force, and records each migration in a tracking table.
Dialects
DBDiff does not flatten everything to one generic SQL dialect. Generated statements stay 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 formats:
- sql
- table
- json
apply asks [y/N] before it writes:
dbdiff apply migration.sql postgres://target