propel-bundle/Command/MigrationUpCommand.php

66 lines
2.3 KiB
PHP
Raw Normal View History

<?php
/**
* This file is part of the PropelBundle package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
2016-02-11 19:14:03 +01:00
namespace Propel\Bundle\PropelBundle\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
2013-10-31 21:39:12 +01:00
use Propel\Generator\Command\MigrationUpCommand as BaseMigrationCommand;
/**
* @author Kévin Gomez <contact@kevingomez.fr>
*/
2013-11-24 17:36:58 +01:00
class MigrationUpCommand extends WrappedCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
parent::configure();
$this
->setName('propel:migration:up')
2014-11-21 15:05:39 +01:00
->setDescription('Execute (only one) next migration')
->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Connection to use. Example: default, bookstore')
->addOption('migration-table', null, InputOption::VALUE_OPTIONAL, 'Migration table name (if none given, the configured table is used)', null)
->addOption('output-dir', null, InputOption::VALUE_OPTIONAL, 'The output directory')
->addOption('fake', null, InputOption::VALUE_NONE, 'Does not touch the actual schema, but marks next migration as executed.')
->addOption('force', null, InputOption::VALUE_NONE, 'Continues with the migration even when errors occur.')
;
}
/**
* {@inheritdoc}
*/
2013-10-31 21:39:12 +01:00
protected function createSubCommandInstance()
{
2013-12-15 15:04:11 +01:00
return new BaseMigrationCommand();
2013-10-31 21:39:12 +01:00
}
2013-10-31 21:39:12 +01:00
/**
* {@inheritdoc}
*/
protected function getSubCommandArguments(InputInterface $input)
{
$defaultOutputDir = $this->getApplication()->getKernel()->getRootDir().'/propel/migrations';
2013-10-31 21:39:12 +01:00
return array(
'--connection' => $this->getConnections($input->getOption('connection')),
'--migration-table' => $input->getOption('migration-table') ?: $this->getMigrationsTable(),
'--output-dir' => $input->getOption('output-dir') ?: $defaultOutputDir,
'--fake' => $input->getOption('fake'),
'--force' => $input->getOption('force'),
);
}
}