barryvdh/laravel-migration-generator
Generate Laravel migration files from an existing database schema. This package by Barry vd. Heuvel inspects your current tables and creates matching migrations, including indexes and foreign keys, making it easy to version-control legacy or inherited databases.
Architecture fit. This is a development-time scaffolding utility, not a runtime library. It introspects a configured database connection and emits Laravel migration classes through an Artisan command. The only architecture concern it legitimately serves is converting a pre-existing, unmanaged schema into a version-controlled migration baseline. It belongs in require-dev, pinned, and absent from any production artifact or deployment pipeline. It is a bridge artifact: generate, review, commit, then hand schema ownership to Laravel's native schema:dump so the migrations become a historical record rather than a permanently regenerated output. Framing it as a one-shot accelerator rather than a dependency is the decision that keeps the architecture clean.
Integration feasibility. Mechanically trivial — Composer install, optional config publish, point at a named connection, run the command. The feasibility question is fidelity, not mechanics. The tool translates what it understands into Laravel's schema builder; views, stored procedures, triggers, partitions, partial indexes, generated columns, check constraints, custom types, spatial types, and DB-specific defaults are approximated or silently dropped. Integration is feasible when the target schema is conventional (tables, PK/FK, indexes, enums) and the acceptance bar is "reviewed draft baseline," not byte-exact replica. Two friction points worth confirming early: a hard transitive dependency on doctrine/dbal (the most common install failure on modern Laravel), and command-name drift between the description (generate:migrations) and the developer walkthrough (migrate:generate) — evidence of version fragmentation the team pins down empirically against php artisan help, not by reading the README.
Technical risk. Dominant risk is lifecycle: archived repository, 246 stars, zero dependents, no upstream security triage, no compatibility path for future Laravel/PHP majors. Secondary risks are correctness (silent omissions that surface later as production schema drift), ordering (foreign-key cycles causing replay failure), and blast radius (a misconfigured connection pointed at a live primary). The low opportunity score reinforces the framing: tactical accelerator, not strategic dependency. Treat archived status as an accepted, time-boxed risk rather than something to engineer around.
Key questions.
composer.json constraint plus doctrine/dbal actually admit it — verified by a spike, not by reading the README?schema:dump tooling.composer.json?Stack fit. Assumes a Laravel application with a working Artisan console and at least one configured connection. It composes alongside, not instead of, the standard migration workflow. Pair it with a dedicated legacy connection entry rather than reusing an existing production config, and generate into a quarantine path (database/migrations/imported) that is visibly distinct from curated migration history — this prevents both accidental promotion of unreviewed files and later re-runs clobbering hand-edited output. For stacks that need ongoing schema management, this tool is the bootstrap and schema:dump is the steady state; the two are sequential, not competitive.
Migration path.
information_schema as ground truth.require-dev, pin the exact version in composer.lock, record the resolved doctrine/dbal version.--only / --skip / --path=database/migrations/imported against the replica only.schema:dump, and either remove the tool or leave it dev-only with a documented expiry.Compatibility. Validate Composer constraints before committing to the approach — archived packages typically cap out one or two Laravel majors behind, and Laravel 5.5-era auto-discovery assumptions may not hold. Test driver behavior against the exact production engine version: MySQL/MariaDB, PostgreSQL, SQLite, and SQL Server differ in what introspection returns and how Laravel renders types. Verify the actual command name and available flags against the installed build, since documentation and reality have already been shown to drift.
Sequencing. Timebox a sandbox spike first; do not run this in parallel with active schema changes on the source. Freeze DDL for the duration of generation and review so the diff is stable. Place this workstream after schema inventory and before any application-level data migration or backfill work, because the baseline defines the contract everything downstream depends on — environment parity, CI migrate:fresh, seeders, ORM modeling. For a medium schema, plan days to roughly a week inclusive of review, versus weeks for manual transcription; that delta is the entire business case and should be stated in the plan as the expected return on the spike.
Maintenance. Effectively zero upstream maintenance. Treat it as an internally owned, vendored utility with a small enough codebase to patch if a PHP/Laravel compatibility break lands. That patch cost must be explicitly accepted up front, and the dependency should carry a defined retirement date rather than indefinite residency in composer.json. The correct posture is "adopt the output, not the dependency" — buy the hour, own the artifact.
Support. Community support is dormant; escalation is internal only. Requires a named owner, a runbook documenting the exact command invocation and pinned versions, and a known-issues list enumerating what the generator drops for this specific schema. The worst outcome is an undocumented utility a future team inherits mid-modernization without context — which is precisely why the archived status and retirement plan belong in the written record.
Scaling. Scaling is schema-size, not traffic. Hundreds of tables and thousands of foreign keys produce long migration chains, slow Artisan runs, and ordering failures on replay; large single runs are also harder to review, which is why scoped --only/--skip runs into a quarantine directory beat one heroic generation. For very large schemas, expect to segment by domain and review in batches. There is no runtime scaling concern because the tool never runs in production.
Failure modes.
legacy connection with read-only credentials and a mandatory replica.Ramp-up. Low engineer ramp-up — a mid-level engineer can run the command in an afternoon. The real ramp-up cost is reviewer expertise: a senior engineer with database depth must own the schema diff, at roughly a day per medium schema. Budget for that reviewer explicitly in the plan; the tool's output is only as trustworthy as the review behind it, and an unreviewed baseline is worse than no baseline because it looks authoritative.
How can I help you explore Laravel packages today?