tobento/app-migration

App migration support.

1.0.1 2022-04-02 16:57 UTC

This package is auto-updated.

Last update: 2022-10-02 17:58:22 UTC


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.

Credits