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

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.

Frequently asked questions about Laravel Migrations Generator
How do I install this package for Laravel?
Run `composer require --dev kitloong/laravel-migrations-generator` in your project. Laravel auto-discovers the package, so no additional setup is needed unless you're using Lumen. For Lumen, manually register the service provider in `bootstrap/app.php` and enable facades.
Which Laravel versions does this package support?
The package supports Laravel 9+ and requires PHP 8.0+. It aligns with Laravel’s first-party database drivers (MySQL, PostgreSQL, SQL Server, SQLite, MariaDB). Always verify compatibility by checking your PHP version with `php -r "echo PHP_VERSION;"` before installation.
Can I generate migrations for specific tables only?
Yes, use the `--tables` flag to target specific tables, e.g., `php artisan migrate:generate --tables="users,posts"`. Alternatively, exclude tables with `--ignore="table1,table2"` to skip them during generation.
Does this handle foreign keys and indexes automatically?
Yes, the package generates Laravel migrations with columns, indexes, and foreign keys. However, circular dependencies may require manual table ordering or the `--squash` flag to combine migrations into a single file.
How do I validate generated migrations before applying them?
Test in a staging environment first. Use `php artisan migrate:fresh` to validate against a clean database, or compare output with manual migrations using `diff` or Laravel Debugbar. For complex schemas, manually review foreign keys and constraints.
Will this work with SQL Server-specific features like computed columns?
The package supports SQL Server but may struggle with non-standard features like computed columns or stored procedures. Test with `--dry-run` first, and manually adjust migrations for unsupported syntax. For edge cases, consider pre-processing your schema.
Can I integrate this into my CI/CD pipeline?
Yes, add it as a pre-merge check in GitHub Actions or similar tools. Example: `php artisan migrate:generate --dry-run --tables="users"`. Use `--dry-run` to preview changes without writing files, ensuring migrations align with your workflow.
How do I handle conflicts if I merge generated migrations with manual changes?
Generated migrations assume a ‘fresh’ schema, so conflicts may arise with manual changes. Use `--with-has-table` to check for existing tables, and manually resolve conflicts by comparing files. Consider adding a comment header (e.g., `// Auto-generated`) to track auto-generated vs. manual migrations.
Does this package support custom migration templates?
Yes, override default templates with the `--template-path` flag. For example, `php artisan migrate:generate --template-path=custom/templates` lets you define custom column or table structures while preserving Laravel’s syntax.
What are the performance considerations for large databases?
Performance degrades with >100 tables. Pre-filter tables with `--tables` or use `--squash` to reduce file count. For large schemas, test with a subset of tables first, and consider splitting migrations into batches for better CI/CD performance.
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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor