tobento / app-migration
App migration support.
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
App migration support.
Table of Contents
Getting Started
Add the latest version of the app migration project running this command.
composer require tobento/app-migration
Requirements
- PHP 8.0 or greater
Documentation
App
Check out the App Skeleton if you are using the skeleton.
You may also check out the App to learn more about the app in general.
Migration Boot
The migration boot does the following:
- definition of \Tobento\Service\Migration\MigratorInterface::class
- definition of \Tobento\Service\Migration\MigrationResultsInterface::class
- installs and loads migration config file
- adds install and uninstall app macros
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();
Install and Uninstall Migration
Once the Migration Boot has been booted you may install migrations by the following ways:
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); } }
Create Migration
Check out the Migration Service to learn more about creating migration classes.
Console
If you have installed the App Console you may run the following commands.
Migration List Command
The migration:list
command provides an overview of all the migrations installed:
php ap migration:list
Migration Install Command
Install a migration by its class:
php ap migration:install --name=Namespace\Migration
Reinstalls all migrations:
php ap migration:install --all
Reinstalls specific migration(s) or/and action(s) by its ids. To get the ids, run migration:list
command:
php ap migration:install --id=12|23
Reinstalls specific migration(s) or/and action(s) by its type.
php ap migration:install --type=database|views
Migration Uninstall Command
Uninstall a migration by its class:
php ap migration:uninstall --name=Namespace\Migration
Uninstalls all migrations:
php ap migration:uninstall --all
Uninstalls specific migration(s) by its ids. To get the ids, run migration:list
command:
php ap migration:uninstall --id=12|23