Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Migrations Generator

Laravel Migrations Generator Laravel Package

kitloong/laravel-migrations-generator

Generate Laravel migration files from an existing database schema, including columns, indexes, and foreign keys. Works with MariaDB/MySQL, PostgreSQL, SQL Server, and SQLite. Generate all tables or target/ignore specific tables via Artisan.

View on GitHub
Deep Wiki
Context7

Generates Laravel Migrations from an existing database

Frequently asked questions about Laravel Migrations Generator
How do I generate Laravel migrations for an existing MySQL database?
Run `php artisan migrate:generate` after installing the package via Composer. The tool automatically inspects your configured Laravel database connection and generates migrations for all tables, including columns, indexes, and foreign keys. For specific tables, use `--tables="table1,table2"`.
Does this package support Laravel 10 or 11?
The package officially supports Laravel 7+ and likely works with newer versions like Laravel 10/11 due to minimal breaking changes in the migration system. However, test thoroughly, as no explicit Laravel 11+ support is documented. Check the GitHub issues for version-specific feedback.
Can I ignore certain tables during migration generation?
Yes, use the `--ignore` flag followed by a comma-separated list of tables, e.g., `php artisan migrate:generate --ignore="temp_table,logs"`. This skips generating migrations for those tables while processing the rest.
Will this tool handle foreign key constraints correctly?
Yes, the package preserves foreign keys during generation, ensuring referential integrity in your migrations. However, if referenced tables are ignored or missing, the generated migrations may fail. Always review the output for circular dependencies or incomplete constraints.
How do I generate migrations for PostgreSQL or SQL Server?
The package supports all Laravel-first-party databases, including PostgreSQL and SQL Server. Simply configure your `.env` or `config/database.php` to use the target database, then run `php artisan migrate:generate`. No additional flags are needed for database-specific support.
Can I customize the generated migration templates?
The package allows template overrides, but customization is limited to structural changes. For application-specific logic (e.g., soft deletes, timestamps), manually edit the generated files post-generation. Check the [documentation](https://kitloong.github.io/laravel-migrations-generator/usage/) for template paths.
Does this package work with Lumen?
Yes, but Lumen requires manual setup: uncomment `$app->withFacades()` in `bootstrap/app.php` and register the provider in the `Register Service Providers` section. The package will then function identically to Laravel, generating migrations via `php artisan migrate:generate`.
What if my database has complex constraints like triggers or check constraints?
The package handles standard constraints (foreign keys, indexes) but may struggle with non-standard SQL features like triggers or check constraints. Generated migrations for these may be incomplete or incorrect. Review and manually adjust such cases post-generation.
How do I handle data migration separately from schema generation?
This package generates schema-only migrations. For data migration, use Laravel’s `DB::table()->insert()` or tools like `laravel-backup` or `spatie/laravel-data-importer`. Alternatively, export data via SQL dumps and import it post-migration.
Are there alternatives to this package for reverse-engineering migrations?
Alternatives include `doctrine/dbal` (for raw schema inspection) or `laravel-schema` (for schema-to-migration tools). However, `kitloong/laravel-migrations-generator` is tailored specifically for Laravel, offering seamless integration with Artisan and Laravel’s Schema builder, making it the most developer-friendly option.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk