Final Class Yiisoft\Db\Migration\Migrator
| Inheritance | Yiisoft\Db\Migration\Migrator |
|---|
Public Methods
Method Details
| public mixed __construct ( \Yiisoft\Db\Connection\ConnectionInterface $db, Yiisoft\Db\Migration\Informer\MigrationInformerInterface $informer, string $historyTable = '{{%migration}}', integer|null $migrationNameLimit = 180, integer|null $maxSqlOutputLength = null ) | ||
| $db | \Yiisoft\Db\Connection\ConnectionInterface | |
| $informer | Yiisoft\Db\Migration\Informer\MigrationInformerInterface | |
| $historyTable | string | |
| $migrationNameLimit | integer|null | |
| $maxSqlOutputLength | integer|null | |
public function __construct(
private readonly ConnectionInterface $db,
private readonly MigrationInformerInterface $informer,
private readonly string $historyTable = '{{%migration}}',
private ?int $migrationNameLimit = 180,
private readonly ?int $maxSqlOutputLength = null,
) {}
| public void down ( Yiisoft\Db\Migration\RevertibleMigrationInterface $migration ) | ||
| $migration | Yiisoft\Db\Migration\RevertibleMigrationInterface | |
public function down(RevertibleMigrationInterface $migration): void
{
$this->checkMigrationHistoryTable();
match ($migration instanceof TransactionalMigrationInterface) {
true => $this->db->transaction(fn() => $this->migrateDown($migration)),
false => $this->migrateDown($migration),
};
}
| public array getHistory ( integer|null $limit = null ) | ||
| $limit | integer|null | |
public function getHistory(?int $limit = null): array
{
$this->checkMigrationHistoryTable();
$query = (new Query($this->db))
->select(['apply_time', 'name'])
->from($this->historyTable)
->orderBy(['apply_time' => SORT_DESC, 'id' => SORT_DESC])
->indexBy('name');
if ($limit > 0) {
$query->limit($limit);
}
/** @psalm-var array<class-string, int|string> */
return $query->column();
}
| public string getHistoryTable ( ) |
public function getHistoryTable(): string
{
return $this->historyTable;
}
| public integer|null getMigrationNameLimit ( ) |
public function getMigrationNameLimit(): ?int
{
if ($this->migrationNameLimit !== null) {
return $this->migrationNameLimit;
}
$tableSchema = $this->db->getSchema()->getTableSchema($this->historyTable);
if ($tableSchema === null) {
return null;
}
$limit = $tableSchema->getColumns()['name']->getSize();
if ($limit === null) {
return null;
}
return $this->migrationNameLimit = $limit;
}
| public void setIo ( \Symfony\Component\Console\Style\SymfonyStyle|null $io ) | ||
| $io | \Symfony\Component\Console\Style\SymfonyStyle|null | |
public function setIo(?SymfonyStyle $io): void
{
$this->informer->setIo($io);
}
| public void up ( Yiisoft\Db\Migration\MigrationInterface $migration ) | ||
| $migration | Yiisoft\Db\Migration\MigrationInterface | |
public function up(MigrationInterface $migration): void
{
$this->checkMigrationHistoryTable();
match ($migration instanceof TransactionalMigrationInterface) {
true => $this->db->transaction(fn() => $this->migrateUp($migration)),
false => $this->migrateUp($migration),
};
}
Signup or Login in order to comment.