tobento / app-migration
应用迁移支持。
1.0.3
2024-02-20 17:34 UTC
Requires
- php: >=8.0
- psr/container: ^2.0
- tobento/app: ^1.0
- tobento/service-config: ^1.0
- tobento/service-dir: ^1.0
- tobento/service-migration: ^1.0
Requires (Dev)
- mockery/mockery: ^1.6
- nyholm/psr7: ^1.4
- phpunit/phpunit: ^9.5
- tobento/app-console: ^1.0.2
- tobento/service-filesystem: ^1.0
- tobento/service-responser: ^1.0
- vimeo/psalm: ^4.0
Suggests
- tobento/app-console: Support for console commands
- tobento/service-responser: Support for render migration messages
README
应用迁移支持。
目录
入门
通过运行此命令添加正在运行的应用迁移项目的最新版本。
composer require tobento/app-migration
要求
- PHP 8.0 或更高版本
文档
应用
如果您正在使用框架,请查看应用框架。
您还可以查看应用以了解更多有关应用的一般信息。
迁移引导
迁移引导执行以下操作
- \Tobento\Service\Migration\MigratorInterface::class的定义
- \Tobento\Service\Migration\MigrationResultsInterface::class的定义
- 安装和加载迁移配置文件
- 添加安装和卸载应用宏
use Tobento\App\AppFactory; // Create the app $app = (new AppFactory())->createApp(); // Adding boots $app->boot(\Tobento\App\Migration\Boot\Migration::class); // Run the app $app->run();
安装和卸载迁移
一旦启动了迁移引导,您可以按照以下方式安装迁移:
use Tobento\App\Boot; use Tobento\App\Migration\Boot\Migration; class AnyServiceBoot extends Boot { public const BOOT = [ // you may ensure the migration boot. Migration::class, ]; public function boot(Migration $migration) { // Install migrations $migration->install(AnyMigration::class); // Uninstall migrations $migration->uninstall(AnyMigration::class); // Install migrations with app macro $this->app->install(AnyMigration::class); // Uninstall migrations with app macro $this->app->uninstall(AnyMigration::class); } }
创建迁移
查看迁移服务以了解更多有关创建迁移类的信息。
控制台
如果您已安装应用控制台,可以运行以下命令。
迁移列表命令
migration:list
命令提供了所有已安装迁移的概览
php ap migration:list
迁移安装命令
通过其类安装迁移
php ap migration:install --name=Namespace\Migration
重新安装所有迁移
php ap migration:install --all
通过其ID重新安装特定的迁移或/和操作。要获取ID,请运行migration:list
命令
php ap migration:install --id=12|23
通过其类型重新安装特定的迁移或/和操作。
php ap migration:install --type=database|views
迁移卸载命令
通过其类卸载迁移
php ap migration:uninstall --name=Namespace\Migration
卸载所有迁移
php ap migration:uninstall --all
通过其ID卸载特定的迁移。要获取ID,请运行migration:list
命令
php ap migration:uninstall --id=12|23