SQL Schema to Laravel Migration.
Turn CREATE TABLE statements from MySQL, PostgreSQL or SQLite into a Laravel migration.
Runs in your browserAbout SQL Schema to Laravel Migration
This converter reads CREATE TABLE statements and writes the matching Laravel migration, so you can move a legacy database or a hand-written schema into version-controlled migrations without retyping every column. It understands the dialects you usually find in dumps: MySQL with backticks, AUTO_INCREMENT, UNSIGNED and ENUM, PostgreSQL with serial, jsonb and timestamptz, and SQLite. Each column becomes the closest Blueprint method, such as string with a length, decimal with precision and scale, boolean for TINYINT(1) and foreignId for BIGINT keys. Modifiers like nullable, default, unique, comment and useCurrent are added from the column definition. With Laravel shortcuts on, nullable created_at and updated_at collapse into timestamps(), deleted_at becomes softDeletes() and remember_token becomes rememberToken(). Foreign keys that point at the id of another table use foreignId()->constrained() with the correct cascade or null-on-delete action, and tables are ordered so that referenced tables are created first. For example, a posts table with user_id BIGINT UNSIGNED REFERENCES users(id) ON DELETE CASCADE turns into foreignId('user_id')->constrained()->cascadeOnDelete(). Typical mistakes the warnings point out are types that have no Blueprint method, such as geometry collections or custom domains, and unsigned decimals, which Laravel no longer supports. Always review the generated file before running php artisan migrate, especially defaults that use database functions. Everything runs locally in your browser; the schema is never uploaded.
How to Use
- Paste one or more CREATE TABLE statements, for example from mysqldump --no-data or pg_dump --schema-only.
- Keep Laravel shortcuts on to get timestamps(), softDeletes() and rememberToken(), or turn them off for a literal copy.
- Copy the migration into database/migrations and check the warnings before running php artisan migrate.
Frequently Asked Questions
Which SQL dialects are supported?
MySQL and MariaDB, PostgreSQL and SQLite CREATE TABLE syntax, including inline and table-level PRIMARY KEY, UNIQUE, INDEX and FOREIGN KEY clauses. ALTER TABLE … ADD FOREIGN KEY and CREATE INDEX statements in the same dump are picked up too.
Why does my BIGINT foreign key become foreignId()?
foreignId() creates an unsigned big integer, which is what Laravel's id() uses. When the column references the id of another table, constrained() adds the foreign key, and the table name is guessed from the column name when it matches.
Does it generate one file per table?
It generates one migration that creates all tables in dependency order and drops them in reverse order in down(). Split it into several files if your project prefers one table per migration.
Is my schema sent to a server?
No. Parsing and code generation run in your browser, and nothing is uploaded or stored.
Related Tools
Convert a SELECT statement into Laravel Query Builder and Eloquent code.
Generate a Laravel Eloquent model, casts and FormRequest validation rules from a sample JSON payload.
Draw an entity-relationship diagram from CREATE TABLE statements or DBML and download it as SVG.
Format and beautify SQL queries.
Generate INSERT statements with realistic fake rows for MySQL, PostgreSQL, SQLite or SQL Server.
Check which versions a Composer constraint like ^8.2 || ~7.4.0 accepts, with stability flags.