mombuyish / laravel-batch-migrations
此包已被弃用且不再维护。没有建议的替代包。
此包的最新版本(0.1.0)没有提供许可证信息。
为 Laravel 批量迁移数据库模式
0.1.0
2017-03-14 02:33 UTC
Requires
- php: >=7.0.0
- laravel/framework: 5.3.*|5.4.*
This package is auto-updated.
Last update: 2020-02-08 15:48:18 UTC
README
它可以批量迁移到数据库。
需求
- laravel 5.3 或更高版本。
- php 7 或更高版本。
情况
有时,您的项目的迁移想要分离文件夹,但您需要添加选项 --path=database/migrations/someone/
或其他,这很好,但我想更 自动
。想象一个命令来完成所有迁移或回滚,就是这样。
例如,我在 database/migrations
中有两个目录
database/
migrations/
testing1/
create_posts_table.php
create_comment_table.php
testing2/
create_articles_table.php
create_messages_table.php
然后您运行 php arisan migrate:batch
它将完成所有迁移。
安装
与其他包一样,使用 composer install 安装此包。例如
$ composer require mombuyish/laravel-batch-migrations
其次,您需要在 config/app.php
中注册服务提供者。
'providers' => [ ... /* * Package Service Providers... */ Mombuyish\BatchMigration\BatchMigrationServiceProvider::class, ...
第三,转到 app/Console/Kernel.php
,添加控制台命令。
protected $commands = [ \Mombuyish\BatchMigration\Commands\BatchMigration::class, \Mombuyish\BatchMigration\Commands\RollbackBatchedMigration::class ];
第四,发布配置。
$ php artisan vendor:publish --provider="Mombuyish\BatchMigration\BatchMigrationServiceProvider"
您可以在配置 batch-migration.php
中进行配置
return [ /** * Accessible paths. */ 'path' => 'database/migrations', ];
最后,您可以查看 $ php artisan
并可以看到两个命令。
migrate:batch Run the database migrations (including depth dictionaries) migrate:batch-rollback Rollback the last database migration (including depth directories)
- 当您运行
php artisan migrate:batch
时,它将在路径中执行所有迁移。 - 当您运行
php artisan migrate:batch-rollback
时,它将回滚您的迁移:批量操作。
支持 --force
注意
当您运行 rollback
时,可能会出现错误。目前,您需要指定目录。 php artisan migrate:rollback --path=database/migrations/someone
。