Abstract Class Yiisoft\Yii\Cycle\Command\Migration\BaseMigrationCommand
| Inheritance | Yiisoft\Yii\Cycle\Command\Migration\BaseMigrationCommand » Symfony\Component\Console\Command\Command |
|---|---|
| Subclasses | Yiisoft\Yii\Cycle\Command\Migration\CreateCommand, Yiisoft\Yii\Cycle\Command\Migration\DownCommand, Yiisoft\Yii\Cycle\Command\Migration\GenerateCommand, Yiisoft\Yii\Cycle\Command\Migration\ListCommand, Yiisoft\Yii\Cycle\Command\Migration\UpCommand |
Protected Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $promise | Yiisoft\Yii\Cycle\Command\CycleDependencyProxy | Yiisoft\Yii\Cycle\Command\Migration\BaseMigrationCommand |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Yii\Cycle\Command\Migration\BaseMigrationCommand |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| createEmptyMigration() | Yiisoft\Yii\Cycle\Command\Migration\BaseMigrationCommand | |
| findMigrations() | Yiisoft\Yii\Cycle\Command\Migration\BaseMigrationCommand |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| MIGRATION_STATUS | [ \Cycle\Migrations\State::STATUS_UNDEFINED => 'undefined', \Cycle\Migrations\State::STATUS_PENDING => 'pending', \Cycle\Migrations\State::STATUS_EXECUTED => 'executed', ] | Yiisoft\Yii\Cycle\Command\Migration\BaseMigrationCommand |
Property Details
Method Details
| public mixed __construct ( Yiisoft\Yii\Cycle\Command\CycleDependencyProxy $promise ) | ||
| $promise | Yiisoft\Yii\Cycle\Command\CycleDependencyProxy | |
public function __construct(protected CycleDependencyProxy $promise)
{
parent::__construct();
}
| protected \Cycle\Schema\Generator\Migrations\MigrationImage|null createEmptyMigration ( \Symfony\Component\Console\Output\OutputInterface $output, string $name, string|null $database = null ) | ||
| $output | \Symfony\Component\Console\Output\OutputInterface | |
| $name | string | |
| $database | string|null | |
protected function createEmptyMigration(
OutputInterface $output,
string $name,
?string $database = null
): ?MigrationImage {
if ($database === null) {
// get default database
$database = $this->promise->getDatabaseProvider()->database()->getName();
}
$migrator = $this->promise->getMigrator();
$migrationSkeleton = new MigrationImage($this->promise->getMigrationConfig(), $database);
$migrationSkeleton->setName($name);
$className = $migrationSkeleton->getClass()->getName();
\assert($className !== null);
try {
$migrationFile = $migrator->getRepository()->registerMigration(
$migrationSkeleton->buildFileName(),
$className,
$migrationSkeleton->getFile()->render()
);
} catch (RepositoryException $e) {
$output->writeln('<fg=yellow>Can not create migration</>');
/**
* @infection-ignore-all
* ConcatOperandRemoval
* Removing closing tag works (probably it's automatically fixed by formatter), but makes no sense.
*/
$output->writeln('<fg=red>' . $e->getMessage() . '</>');
return null;
}
$output->writeln('<info>New migration file has been created</info>');
$output->writeln("<fg=cyan>$migrationFile</>");
return $migrationSkeleton;
}
| protected \Cycle\Migrations\MigrationInterface[] findMigrations ( \Symfony\Component\Console\Output\OutputInterface $output ) | ||
| $output | \Symfony\Component\Console\Output\OutputInterface | |
protected function findMigrations(OutputInterface $output): array
{
$list = $this->promise->getMigrator()->getMigrations();
$output->writeln(
sprintf(
'<info>Total %d migration(s) found in %s</info>',
count($list),
$this->promise->getMigrationConfig()->getDirectory()
)
);
return $list;
}
Signup or Login in order to comment.