Final Class Yiisoft\Db\Migration\Runner\UpdateRunner
| Inheritance | Yiisoft\Db\Migration\Runner\UpdateRunner |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Db\Migration\Runner\UpdateRunner | |
| run() | Yiisoft\Db\Migration\Runner\UpdateRunner | |
| setIo() | Yiisoft\Db\Migration\Runner\UpdateRunner |
Method Details
| public mixed __construct ( Yiisoft\Db\Migration\Migrator $migrator ) | ||
| $migrator | Yiisoft\Db\Migration\Migrator | |
public function __construct(
private readonly Migrator $migrator,
) {}
| 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>',
);
}
Signup or Login in order to comment.