Database Migration Generator — Schema Diff to Up / Down SQL
Database Migration Generator
Paste the current schema on the left and the target schema on the right —
either as CREATE TABLE DDL or as schema JSON from the
ERD Designer — then generate a forward (up) script
and the matching rollback (down) script: new and dropped tables, added, removed and altered
columns, and foreign key changes, quoted for MySQL, PostgreSQL, SQL Server, SQLite, Oracle or standard SQL.
Nothing is uploaded; the diff runs in your browser.
1 — Before (current schema)
2 — After (target schema)
3 — Generate migration
Statements are grouped per table; review the output before running it.
No diff generated yet.
Scope: this is a structural diff of tables, columns, primary keys, nullability,
defaults and foreign keys. Indexes, triggers, views and data back-fills are out of scope and should be
added by hand. SQLite cannot alter a column in place, so those changes are emitted as a comment asking you
to recreate the table.
What is a database migration?
A migration is a versioned script that changes a database schema: create this table, add that column, drop an index. Teams apply migrations in order so every environment — dev, staging, production — walks the same path from version to version instead of being edited by hand into shapes that no longer match the code. Each migration normally ships in two halves: up applies the change, down reverses it, so a bad release can be rolled back the same way it went in.
Migrations that drop tables or columns are destructive — the down script cannot resurrect deleted data. Back up (or at least export the affected tables) before running a migration that removes anything.