Database Migration Generator

A SQL schema diff that reads two versions of your tables and writes the ALTER TABLE statements between them.

Drop your current schema on the left and the schema you want on the right, both as plain CREATE TABLE DDL, and this tool works out the difference and writes the migration for you. It compares the two side by side and emits CREATE TABLE for anything new, DROP TABLE for anything gone, and ADD COLUMN, DROP COLUMN or an ALTER for every column whose type or nullability moved. Pick PostgreSQL or MySQL and the ALTER syntax follows suit — Postgres gets separate ALTER COLUMN … TYPE and SET NOT NULL statements, MySQL gets a single MODIFY COLUMN. Flip on the down migration and you get the exact rollback to undo it.

1 table added · 1 dropped · 1 column added · 1 removed · 1 altered
Old schema (current)
New schema (target)
Migration SQL

How it works

  1. 1

    Paste the current schema

    In the left pane put the CREATE TABLE statements for the database as it stands today — the version you are migrating away from. Multiple tables in one block are fine.

  2. 2

    Paste the target schema

    In the right pane put the CREATE TABLE statements for how you want the schema to look. Change a VARCHAR length, add a column, drop a table — the diff engine picks up each edit.

  3. 3

    Pick a dialect and read the migration

    Choose PostgreSQL or MySQL, toggle the down migration if you want a rollback, then copy the generated ALTER/CREATE/DROP SQL or download it as migration.sql.

Instant & 100% private — nothing is uploaded

Everything runs locally in your browser. Your code, text and files are processed on your own device and are never sent to a server — so there are no upload waits, no size limits from us, and nothing is ever stored or logged.

Frequently asked questions

What migration SQL does it generate from a schema change?
Take old = CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50)) and new = CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(100), email VARCHAR(255)). On PostgreSQL it produces: ALTER TABLE users ADD COLUMN email VARCHAR(255); and ALTER TABLE users ALTER COLUMN name TYPE VARCHAR(100); — the new column added and the widened type altered, in one ordered script.
Does it handle new tables and dropped tables, not just columns?
Yes. A table that exists only in the new schema is emitted as a full CREATE TABLE with all its columns; a table that exists only in the old schema becomes DROP TABLE. Column-level ADD, DROP and ALTER only run for tables present on both sides.
How is the down migration built?
It is the mirror image of the up migration. An added column becomes a DROP COLUMN, a dropped column is added back with its old definition, a new table is dropped, a removed table is recreated, and every altered column reverts to its previous type, nullability and default.
What is the difference between the PostgreSQL and MySQL output?
For a changed column, Postgres emits granular statements — ALTER TABLE t ALTER COLUMN c TYPE …, SET NOT NULL / DROP NOT NULL, SET DEFAULT / DROP DEFAULT. MySQL restates the whole column in one line: ALTER TABLE t MODIFY COLUMN c VARCHAR(100) NOT NULL. Switching the dialect selector rewrites the ALTER syntax without you touching the schemas.