SQL Migration Generator — Generate Database Migrations from Visual Diffs

Writing database migration scripts by hand is one of the most error-prone tasks in software development. Miss a column, forget an index, or reverse the direction of a foreign key and you've got a production incident. ER Flow's migration generation feature eliminates this risk by automatically diffing your schema against a saved checkpoint and producing a precise, ready-to-run migration file.

The migration workflow is built around checkpoints. When your schema reaches a stable state — after a sprint, before a deployment, or at any meaningful milestone — save a checkpoint. Continue designing: add tables for new features, modify columns, add indexes. When you're ready to deploy, open the migration generator. ER Flow diffs your current schema against the last checkpoint and shows you every table created, every column modified, every index added. Click generate and get a migration file that captures exactly those changes.

ER Flow generates migrations for multiple frameworks. Laravel developers get complete migration files with up() and down() methods. Phinx users get PHP migration classes. Raw SQL output is available for any database system. All generated migrations include both the forward migration and the rollback — because production deployments always need a safe exit.

How It Works

Checkpoint-Based Schema Diffing

Save a checkpoint of your schema at any point. ER Flow tracks every subsequent change against that baseline. The diff engine compares column types, nullability, default values, indexes, and foreign keys — producing a complete, accurate change set.

Laravel Migration Generation

Generate complete Laravel migration files with Schema::create, Schema::table, up() and down() methods. ER Flow maps every column type and constraint to the correct Laravel fluent builder call.

Phinx Migration Generation

Generate Phinx PHP migration classes for teams using the Phinx migration library with CakePHP, Slim, or standalone. ER Flow produces correct up() and rollback() methods with proper column type mappings.

Raw SQL Export

Export a raw SQL migration script compatible with any relational database. The diff produces CREATE TABLE, ALTER TABLE, ADD COLUMN, DROP COLUMN, and ADD CONSTRAINT statements for the exact changes made since the checkpoint.

Use Cases

Generate a Laravel migration for a sprint's worth of schema changes with a single click
Create an ALTER TABLE script to add an audit log table to a production PostgreSQL database
Build a complete initial schema migration for a new MySQL application from the visual diagram
Generate a Phinx rollback migration to safely revert a failed database deployment

Generate your first schema migration — free to start

Free to get started. No credit card required.