From cfedbd0d96f70ae36fbb2cc20b3595a487a18ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Mon, 14 Jul 2014 15:12:42 +0100 Subject: [PATCH] Add propel:migration:diff command --- Command/MigrationDiffCommand.php | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Command/MigrationDiffCommand.php diff --git a/Command/MigrationDiffCommand.php b/Command/MigrationDiffCommand.php new file mode 100644 index 0000000..8bae9bb --- /dev/null +++ b/Command/MigrationDiffCommand.php @@ -0,0 +1,69 @@ + + */ +class MigrationDiffCommand extends WrappedCommand +{ + /** + * {@inheritdoc} + */ + protected function configure() + { + parent::configure(); + + $this + ->setName('propel:migration:diff') + ->setDescription('Generate diff classes') + + ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Connection to use. Example: default, bookstore') + ->addOption('output-dir', null, InputOption::VALUE_OPTIONAL, 'The output directory') + ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name', BaseMigrationCommand::DEFAULT_MIGRATION_TABLE) + ->addOption('table-renaming', null, InputOption::VALUE_NONE, 'Detect table renaming', null) + ->addOption('editor', null, InputOption::VALUE_OPTIONAL, 'The text editor to use to open diff files', null) + ->addOption('skip-removed-table', null, InputOption::VALUE_NONE, 'Option to skip removed table from the migration') + ->addOption('skip-tables', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'List of excluded tables', array()) + ; + } + + /** + * {@inheritdoc} + */ + protected function createSubCommandInstance() + { + return new BaseMigrationCommand(); + } + + /** + * {@inheritdoc} + */ + protected function getSubCommandArguments(InputInterface $input) + { + $defaultOutputDir = $this->getApplication()->getKernel()->getRootDir().'/propel/migrations'; + + return array( + '--connection' => $this->getConnections($input->getOption('connection')), + '--migration-table' => $input->getOption('migration-table'), + '--output-dir' => $input->getOption('output-dir') ?: $defaultOutputDir, + '--table-renaming' => $input->getOption('table-renaming'), + '--editor' => $input->getOption('editor'), + '--skip-removed-table' => $input->getOption('skip-removed-table'), + '--skip-tables' => $input->getOption('skip-tables'), + ); + } +}