The CollectionInstrument No. 08
dbdiff
Schema drift, answered in the SQL your dialect actually speaks.
The Problem
Comparing two databases still means bouncing between GUI tools, export scripts, and dialect-specific incantations. And when a migration script is generated, the details that matter — how MySQL alters a column versus how PostgreSQL does — get flattened into something that runs on neither.
The Insight
Finding the diff is the easy part. Emitting correct DDL per dialect is the product.
The Instrument
dbdiff compares two PostgreSQL, MySQL 8+ or SQL Server schemas and generates the migration in that engine’s own dialect — MODIFY COLUMN for MySQL, ALTER COLUMN TYPE … USING for PostgreSQL, ALTER COLUMN with its DEFAULT constraint dropped and restored for SQL Server — written from the source database’s own definitions and ordered by dependency.
compare and migrate only read the databases; apply asks for confirmation before it runs a migration, unless --force, and records each one in a tracking table. By default each migration file is wrapped in its dialect’s transaction statements and sets a lock timeout; ignore patterns and protected objects keep chosen columns and objects out of it, and migration files and logs show connection strings with the password masked. Reports come in SQL, table or JSON. One CLI from inspection to reviewed migration file.
Review, then apply
$ export SHOP=postgres://app:s3cret@localhost:5432/shop
$ export LIVE=postgres://app:s3cret@localhost:5432/shop_live
$ dbdiff migrate -s "$SHOP" -t "$LIVE" -o migration.sql
$ cat migration.sql
-- DBDiff Migration
-- Source: postgres://app:***@localhost:5432/shop
-- Target: postgres://app:***@localhost:5432/shop_live
-- Schema: public
BEGIN;
SET lock_timeout = '10s';
-- Add column: last_seen to users
ALTER TABLE users ADD COLUMN last_seen timestamp with time zone NULL;
-- Alter column: users.email
-- Type changed
-- Old: character varying(255)
-- New: text
ALTER TABLE users ALTER COLUMN email TYPE text USING (email::text);
-- Drop table: legacy_sessions
DROP TABLE IF EXISTS legacy_sessions CASCADE;
-- Drop sequence: legacy_sessions_id_seq
DROP SEQUENCE IF EXISTS legacy_sessions_id_seq;
COMMIT;
$ dbdiff apply migration.sql "$LIVE"
You are about to apply migration 'migration.sql' to target database.
Are you sure you want to proceed? [y/N]: y
$ dbdiff compare "$SHOP" "$LIVE"
No differences found.
Real session with dbdiff v1.1.5 on PostgreSQL 16: migrate only writes the file, apply asks before it runs it and records it, and compare then finds nothing left to change.
Spec
- Databases
- PostgreSQL · MySQL 8.0+ · SQL Server
- Generation
- Dialect-aware DDL per engine
- Safety
- Read-only compare and migrate · apply asks before running · transaction wrapper · protected objects
- Output
- SQL · Table · JSON
- Install
- go install · Homebrew tap · release binaries
- Quick start
go install github.com/meru143/dbdiff@latest
The Outcome
dbdiff v1.1.5 shipped on 29 October 2026 with binaries for Linux, macOS and Windows on amd64 and arm64, and a Homebrew formula. On every push to main and every pull request into it, CI applies a generated migration to real PostgreSQL 16, MySQL 8.0 and SQL Server 2022 servers and requires zero remaining differences. Drift inspection and migration generation live in one reviewed file, in the dialect that will actually execute it.