Compare Database Migrations Online

Paste two SQL migration scripts. See what was added, removed, or changed — statement by statement.

🔒 100% private — runs entirely in your browser

or try sample data

What is Database Migration Diff?

Database Migration Diff compares two SQL migration scripts and shows you exactly which statements were added, removed, or modified. Whether you're reviewing schema changes, comparing migration versions, or auditing ALTER TABLE statements, this tool gives you a clear view of every difference.

Database migrations are high-stakes changes — a missing constraint, wrong data type, or forgotten index can cause data loss, downtime, or performance problems. Comparing migrations side by side before running them catches issues that code review alone might miss.

The tool works with any SQL dialect (PostgreSQL, MySQL, SQLite, SQL Server) and any migration framework (Knex, Prisma, Django, Rails, Flyway, Liquibase). Paste your raw SQL and see the diff. The "Ignore case" option helps when comparing SQL from different sources where keyword casing varies.

Database Migration Comparison — Common Scenarios

Comparing CREATE TABLE versions

-- Version 1: Basic users table
CREATE TABLE users ( id SERIAL PRIMARY KEY, email VARCHAR(255) NOT NULL, created_at TIMESTAMP DEFAULT NOW()
); -- Version 2: Added constraints and columns
CREATE TABLE users ( id SERIAL PRIMARY KEY, email VARCHAR(255) NOT NULL UNIQUE, role VARCHAR(20) DEFAULT 'user', created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), deleted_at TIMESTAMP WITH TIME ZONE
);

The diff highlights the UNIQUE constraint addition, new role column, timezone-aware timestamps, and soft delete column.

Reviewing ALTER TABLE changes

-- Proposed migration
ALTER TABLE orders ADD COLUMN discount_pct DECIMAL(5,2);
ALTER TABLE orders ALTER COLUMN total SET NOT NULL;
CREATE INDEX idx_orders_status ON orders (status); -- Revised after review
ALTER TABLE orders ADD COLUMN discount_pct DECIMAL(5,2) DEFAULT 0;
ALTER TABLE orders ALTER COLUMN total SET NOT NULL;
ALTER TABLE orders ADD CONSTRAINT chk_discount CHECK (discount_pct >= 0 AND discount_pct <= 100);
CREATE INDEX CONCURRENTLY idx_orders_status ON orders (status);

Review catches: missing DEFAULT value, added CHECK constraint, and CONCURRENTLY keyword for zero-downtime index creation.

Database Migration Comparison Gotchas

Statement ordering matters

SQL statements often depend on each other (e.g., CREATE TABLE before CREATE INDEX). Reordering statements in a migration can cause failures. The diff shows line-level changes, so pay attention to moved statements — they appear as removed + added rather than reordered.

Irreversible migrations

Some operations like DROP COLUMN or DROP TABLE destroy data permanently. If your diff shows these statements, verify that data has been backed up or migrated before running the migration.

SQL keyword case sensitivity

SQL keywords are case-insensitive (CREATE TABLE = create table), but the diff tool is case-sensitive by default. Enable "Ignore case" when comparing SQL from different sources or developers who use different casing conventions.

Frequently Asked Questions

How do I compare two SQL migration files?

Paste your SQL migration scripts into the two panels and click Compare. The tool highlights added, removed, and modified lines with word-level highlighting so you can see exactly what changed.

Does this work with any database?

Yes. The tool performs text-based comparison, so it works with PostgreSQL, MySQL, SQLite, SQL Server, Oracle, or any SQL dialect. It compares the raw SQL text regardless of database engine.

Can I compare up and down migrations?

Yes. Comparing your up (forward) and down (rollback) migrations is a great way to verify that the down migration correctly reverses all changes made in the up migration.

Is my SQL data safe?

Yes. This tool runs entirely in your browser. Your migration scripts, table names, and schema details are never sent to any server.

Can I use this with ORM-generated migrations?

Yes. ORMs like Prisma, Django, Rails, and Sequelize generate SQL migration files. You can paste the generated SQL from any ORM and compare versions.