setAliases(['generate'])
->setDescription('Generate a blank migration class.')
->addOption(
'namespace',
null,
InputOption::VALUE_REQUIRED,
'The namespace to use for the migration (must be in the list of configured namespaces)',
)
->setHelp(<<<'EOT'
The %command.name% command generates a blank migration class:
%command.full_name%
EOT);
parent::configure();
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$migrationGenerator = $this->getDependencyFactory()->getMigrationGenerator();
$namespace = $this->getNamespace($input, $output);
$fqcn = $this->getDependencyFactory()->getClassNameGenerator()->generateClassName($namespace);
$path = $migrationGenerator->generateMigration($fqcn);
$this->io->text([
sprintf('Generated new migration class to "%s"', $path),
'',
sprintf(
'To run just this migration for testing purposes, you can use migrations:execute --up \'%s\'',
$fqcn,
),
'',
sprintf(
'To revert the migration you can use migrations:execute --down \'%s\'',
$fqcn,
),
'',
]);
return 0;
}
}