Final Class Yiisoft\Db\Migration\Runner\UpdateRunner
| Inheritance | Yiisoft\ |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| run() | Yiisoft\ |
|
| setIo() | Yiisoft\ |
Method Details
| public mixed __construct ( Yiisoft\ | ||
| $migrator | Yiisoft\ |
|
public function __construct(
private readonly Migrator $migrator,
) {}
| public void run ( Yiisoft\ | ||
| $migration | Yiisoft\ |
|
| $number | ?int | |
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>',
);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.