Laravel Migrations Generator
Laravel Migrations Generator stats
- Downloads
- 2.4M
- Stars
- 1,983
- Open Issues
- 2
- Forks
- 234
Generates Laravel Migrations from an existing database
Laravel Migrations Generator Summary
The Laravel Migrations Generator is a robust package designed to automatically generate migration files from an existing database, including the creation of indexes and foreign keys. This tool is crucial for developers looking to migrate databases seamlessly within the Laravel framework.
Key Features
- Database Support: Compatible with all major databases supported by Laravel, including MariaDB, MySQL, PostgreSQL, SQL Server, and SQLite.
- Version Compatibility: Fully supports Laravel versions from 5.6 and above.
- Customizable Migrations: Provides options to specify which tables to include or ignore during the migration generation process.
- Single File Option: Ability to squash all migrations into a single file for streamlined management.
- Extended Functionality: Supports generating views, stored procedures, and handling custom column types for certain databases.
Installation and Setup
Install via Composer:
composer require --dev kitloong/laravel-migrations-generator
For Laravel
The package auto-registers the service provider.
For Lumen
Manual modifications are needed:
- Enable facades in
bootstrap/app.php. - Register the
MigrationsGeneratorServiceProvider.
Usage
Ensure your database configuration is set in config/database.php. Generate migrations with:
php artisan migrate:generate
Options include specifying tables to generate or ignore, setting the path for migration files, and more.
To generate a single migration file from multiple migrations, use:
php artisan migrate:generate --squash
Advanced Features
- SQLite Limitations: Handles SQLite's restrictions on altering foreign keys after table creation.
- User-Defined Custom Column Types: For PostgreSQL and SQL Server, allows custom data types and alters table schemas accordingly.
This package, building on the work by Bernhard Breytenbach, facilitates the easy generation of migration files, aiding developers in maintaining and versioning database structures efficiently.