Skip to content

micross/Laravel-Migration-Generator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Migration Generator

Latest Stable Version Total Downloads License Travis Build Status

⚠️ WORK IN PROGRESS ⚠️

Generate Laravel migration files from existing databases.

Installation

composer require romanzipp/laravel-migration-generator

If you use Laravel 5.5+ you are already done, otherwise continue.

Add Service Provider to your app.php configuration file:

romanzipp\MigrationGenerator\Providers\MigrationGeneratorProvider::class,

Configuration

Copy configuration to config folder:

$ php artisan vendor:publish --provider="romanzipp\MigrationGenerator\Providers\MigrationGeneratorProvider"

Usage

php artisan mg:generate {--connection=}

You will see various new migration files prefixed with the current time & date.

Notice: This package can't guess the order in which migrations will be created. If you've created some foreign keys in your database, be sure to re-order the migration files based on these relations.

Supported Databases

Features

  • Tables
  • Columns
  • Column modifiers (nullable, default, ...)
  • Indexes
  • Foreign keys

Testing

There are Travis tests with the following matrix.

  • PHP Versions
    • 7.2
    • 7.3
    • 7.4
  • Databases
    • SQLite
    • MySQL
    • MariaDB
  • Composer packages
    • latest
    • lowest

SQLite

./vendor/bin/phpunit

MySQL / MariaDB

Requires a running MySQL / MariaDB server

./vendor/bin/phpunit -c phpunit.mysql.xml

Provide database environment variables

DB_HOST=127.0.0.1 DB_USERNAME=user DB_PASSWORD=secret ./vendor/bin/phpunit -c phpunit.mysql.xml

Known issues

  • MariaDB: The JSON MySQL data type is not supported since Doctrine/DBAL interprets this as Doctrine\DBAL\Types\TextType
  • MySQL: Doctrine/DBAL can't differentiate between TEXT, LONGTEXT, MEDIUMTEXT

About

⚠️ WIP ⚠️ - Generate Laravel migration files from existing databases

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%