Laravel Cloud is here! Zero-config managed infrastructure for Laravel apps. Deploy now.

Laravel Migrations Generator

kitloong/laravel-migrations-generator image

Laravel Migrations Generator stats

Downloads
2.4M
Stars
1,983
Open Issues
2
Forks
234

View on GitHub →

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:

  1. Enable facades in bootstrap/app.php.
  2. 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.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Kitloong Laravel Migrations Generator Related Articles

Laravel Introduces Official AI Documentation image

Laravel Introduces Official AI Documentation

Read article
Handling Geospatial Data with Laravel Magellan image

Handling Geospatial Data with Laravel Magellan

Read article
Laravel API Toolkit image

Laravel API Toolkit

Read article
Generate Migrations from an Existing Database With the Migration Generator Package image

Generate Migrations from an Existing Database With the Migration Generator Package

Read article
Laravel 8 is Now Released! image

Laravel 8 is Now Released!

Read article
Some new features coming to Laravel 8 image

Some new features coming to Laravel 8

Read article
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm