Skip to content
migration.tools
SQL DDL to Laravel

SQL to Laravel migration converter

Bringing a legacy database under Laravel's migrations? Paste the existing schema and get an anonymous migration class with a Schema::create block per table, foreign keys added after every table exists, and a down() method that drops them in reverse order.

Options

CREATE TABLE statements

Laravel migration

The result appears here as soon as there is input.

Processed on this device. Nothing you paste or drop is uploaded.

How to use it

  1. 1Paste your SQL DDL or drop a file onto the input panel.
  2. 2Adjust the options — the result updates as you type.
  3. 3Copy the Laravel or download it. Drop several files to convert a batch into one ZIP.

What the migration contains

Column types map to Blueprint methods — id(), string(), unsignedInteger(), decimal(), enum(), json(), longText() and the rest — with ->nullable(), ->default(), ->unique(), ->useCurrent() and ->comment() chained on as needed.

A nullable created_at and updated_at pair collapses to $table->timestamps(), and deleted_at to $table->softDeletes(), so the result reads like a migration a person would write.

Foreign keys go in a second Schema::table pass, which means the migration runs no matter which order your dump listed the tables in.

Questions

Which Laravel versions is the output for?

It uses the anonymous-class migration style introduced in Laravel 8 and standard in Laravel 9 through 12. For older versions, give the class a name.

Can I get one migration file per table?

The output is a single file so foreign keys can be added after all tables exist. If you prefer one file per table, split the Schema::create blocks and keep the foreign-key block in the last migration.