laravel5.8
安装
composer require --dev "xethron/migrations-generator"
配置
1、修改文件 config/app.php,添加相应的服务提供者
'providers' => [
//......
Way\Generators\GeneratorsServiceProvider::class,
Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider::class,
],
2、修改app/Providers/AppServiceProvider.php,注册服务
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"
生成文件在database/migrations目录下
查看更多用法
php artisan help migrate:generate
migrate:generate [options] [--] [<tables>]