已有数据库自动生成migration迁移文件--分享一些好用的包3

Laravel php composer 1595      收藏
已有的数据库需要生成migration迁移文件可以使用此包快速生成。

已有的数据库需要生成migration迁移文件可以使用此包快速生成迁移文件,包括索引和外键。

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

Github地址:https://github.com/Xethron/migrations-generator


Laravel5安装

composer require --dev "xethron/migrations-generator"

老的版本需要在config/app.php文件中添加如下命令

Way\Generators\GeneratorsServiceProvider::class,
Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider::class,

如果只是想要在开发环境中使用此包的话,可以在文件app/Providers/AppServiceProvider.phpregister()中添加如下代码

public function register(){    
    if ($this->app->environment() !== 'production') {        
        $this->app->register(\Way\Generators\GeneratorsServiceProvider::class);        
        $this->app->register(\Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider::class);    
    }    
    // ...
}

使用方法

创建全部表的迁移文件

php artisan migrate:generate

创建指定表的迁移文件

php artisan migrate:generate table1,table2,table3,table4,table5

生成除了指定表之外的全部表迁移文件

php artisan migrate:generate --ignore="table3,table4,table5"