kitloong/laravel-migrations-generator
Generate Laravel migrations from an existing database, complete with indexes and foreign keys. Supports MariaDB, MySQL, PostgreSQL, SQL Server and SQLite, with options to include, exclude or target specific tables via Artisan.
Schema::create calls that must match the existing schema exactly. It lets us scope the Laravel migration as an application-layer rewrite rather than a schema rewrite.artisan command that introspects INFORMATION_SCHEMA, pg_catalog, sqlite_master, and SQL Server system tables — across columns, indexes, foreign keys, views, stored procedures, generated/virtual columns, enums, table comments, and user-defined types — is a multi-sprint effort with a long tail of dialect bugs. Buying (at MIT license, zero cost) is the clear call. Adopt rather than build unless we have a database platform it does not cover.php artisan migrate:generate --squash produces a reviewable schema baseline. That de-risks the rest of the plan, because CI, seeders, model scaffolding, and test fixtures all depend on a reproducible schema existing first.--tables / --ignore for incremental table-by-table cutover; --skip-views, --skip-proc, --skip-foreign-keys to defer hard problems (views and stored procedures usually belong to a later phase, or are deliberately dropped); --connection for parallel-run against a replica.--log-with-batch=0 gives a fast path to a schema-faithful test database, which unblocks integration testing before the application rewrite is far along.--squash (one file) vs. per-table files is a real product choice: squash for a clean single baseline commit on greenfield-ish replatforms, per-table for teams that will iterate on individual tables during a phased cutover.Consider adoption when most of these hold:
Look elsewhere, or treat as insufficient on its own, when:
reliese/laravel or similar); plan accordingly.--dev dependency never shipped to production, but governance review should note it.One line: A free, MIT-licensed developer tool that turns an existing database into Laravel migration files automatically — including indexes, foreign keys, views, and stored procedures — so a legacy-database replatform starts from an accurate schema instead of weeks of manual transcription.
To executives: It removes a large, low-value, high-risk block of work from the modernization critical path. The alternative — hand-writing migrations for an inherited schema — is pure cost with no product differentiation, and it is where subtle bugs (wrong index, missing FK, mismatched column type) hide until production. We can generate a reviewable schema baseline in an afternoon, which makes the rest of the roadmap easier to estimate and lets us demonstrate progress to stakeholders early. Cost is zero; it is a development-time dependency and never ships to production. The main thing we are buying is schedule confidence, not a feature.
To engineering: It is a composer require --dev package with a service provider auto-registered, invoked as php artisan migrate:generate, and configured through the existing config/database.php connections. It supports all five first-party Laravel databases and tracks the current framework (Laravel 13 in v7.3.0, Laravel 12.20 default-value escaping in v7.2.0). Practical guidance: generate with --squash for a single reviewable baseline or leave it per-table if we are cutting over incrementally; use --tables and --ignore to control scope; use --skip-views, --skip-proc, and --skip-foreign-keys to defer what belongs in a later phase; use --log-with-batch=0 so the baseline sorts first; and use --default-index-names / --default-fk-names if we want Laravel's naming conventions rather than the legacy database's. Two explicit caveats: the generated files are a starting point that must be code-reviewed and verified by running migrations against a restored dump, and the tool is one-directional — after generation, our migrations are the source of truth and the legacy database must not be treated as a schema oracle. Budget for a post-generation normalization pass regardless of how clean the output looks.
How can I help you explore Laravel packages today?