0 follower

Final Class Yiisoft\Db\Migration\Runner\UpdateRunner

InheritanceYiisoft\Db\Migration\Runner\UpdateRunner

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\Db\Migration\Migrator $migrator )
$migrator Yiisoft\Db\Migration\Migrator

                public function __construct(
    private readonly Migrator $migrator,
) {}

            
run() public method

public void run ( Yiisoft\Db\Migration\MigrationInterface $migration, integer|null $number null )
$migration Yiisoft\Db\Migration\MigrationInterface
$number integer|null

                public function run(MigrationInterface $migration, ?int $number = null): void
{
    if ($this->io === null) {
        throw new RuntimeException('You need to set output decorator via `setIo()`.');
    }
    $num = $number !== null ? $number . '. ' : '';
    $className = $migration::class;
    $this->io->title("\n{$num}Applying $className");
    $start = microtime(true);
    try {
        $this->migrator->up($migration);
    } catch (Throwable $e) {
        $time = microtime(true) - $start;
        $this->io->writeln(
            "\n\n\t<error>>>> [ERROR] - Not applied (time: " . sprintf('%.3f', $time) . 's)</error>',
        );
        throw $e;
    }
    $time = microtime(true) - $start;
    $this->io->writeln(
        "\n\t<info>>>> [OK] - Applied (time: " . sprintf('%.3f', $time) . 's)</info>',
    );
}

            
setIo() public method

public void setIo ( \Symfony\Component\Console\Style\SymfonyStyle|null $io )
$io \Symfony\Component\Console\Style\SymfonyStyle|null

                public function setIo(?SymfonyStyle $io): void
{
    $this->io = $io;
}