diff --git a/Command/AbstractCommand.php b/Command/AbstractCommand.php index f50b947..149ae6e 100644 --- a/Command/AbstractCommand.php +++ b/Command/AbstractCommand.php @@ -316,6 +316,18 @@ abstract class AbstractCommand extends ContainerAwareCommand return null; } + /** + * Returns the name of the migrations table. + * + * @return string + */ + protected function getMigrationsTable() + { + $config = $this->getContainer()->getParameter('propel.configuration'); + + return $config['migrations']['tableName']; + } + /** * Returns the name of the default connection. * diff --git a/Command/MigrationDiffCommand.php b/Command/MigrationDiffCommand.php index b83624e..0bdb09a 100644 --- a/Command/MigrationDiffCommand.php +++ b/Command/MigrationDiffCommand.php @@ -33,7 +33,7 @@ class MigrationDiffCommand extends WrappedCommand ->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', null) + ->addOption('migration-table', null, InputOption::VALUE_OPTIONAL, 'Migration table name (if none given, the configured table is used)', null) ->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') @@ -58,7 +58,7 @@ class MigrationDiffCommand extends WrappedCommand return array( '--connection' => $this->getConnections($input->getOption('connection')), - '--migration-table' => $input->getOption('migration-table'), + '--migration-table' => $input->getOption('migration-table') ?: $this->getMigrationsTable(), '--output-dir' => $input->getOption('output-dir') ?: $defaultOutputDir, '--table-renaming' => $input->getOption('table-renaming'), '--editor' => $input->getOption('editor'), diff --git a/Command/MigrationDownCommand.php b/Command/MigrationDownCommand.php index 6b57652..f0a5182 100644 --- a/Command/MigrationDownCommand.php +++ b/Command/MigrationDownCommand.php @@ -32,7 +32,7 @@ class MigrationDownCommand extends WrappedCommand ->setDescription('Execute migrations down') ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Connection to use. Example: default, bookstore') - ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name', BaseMigrationCommand::DEFAULT_MIGRATION_TABLE) + ->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') ; } @@ -54,7 +54,7 @@ class MigrationDownCommand extends WrappedCommand return array( '--connection' => $this->getConnections($input->getOption('connection')), - '--migration-table' => $input->getOption('migration-table'), + '--migration-table' => $input->getOption('migration-table') ?: $this->getMigrationsTable(), '--output-dir' => $input->getOption('output-dir') ?: $defaultOutputDir, ); } diff --git a/Command/MigrationStatusCommand.php b/Command/MigrationStatusCommand.php index 3fc7ef8..68c9eeb 100644 --- a/Command/MigrationStatusCommand.php +++ b/Command/MigrationStatusCommand.php @@ -32,7 +32,7 @@ class MigrationStatusCommand extends WrappedCommand ->setDescription('Get migration status') ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Connection to use. Example: default, bookstore') - ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name', BaseMigrationCommand::DEFAULT_MIGRATION_TABLE) + ->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') ; } @@ -54,7 +54,7 @@ class MigrationStatusCommand extends WrappedCommand return array( '--connection' => $this->getConnections($input->getOption('connection')), - '--migration-table' => $input->getOption('migration-table'), + '--migration-table' => $input->getOption('migration-table') ?: $this->getMigrationsTable(), '--output-dir' => $input->getOption('output-dir') ?: $defaultOutputDir, ); } diff --git a/Command/MigrationUpCommand.php b/Command/MigrationUpCommand.php index fd301c6..c8b0f66 100644 --- a/Command/MigrationUpCommand.php +++ b/Command/MigrationUpCommand.php @@ -32,7 +32,7 @@ class MigrationUpCommand extends WrappedCommand ->setDescription('Execute migrations up') ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Connection to use. Example: default, bookstore') - ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name', BaseMigrationCommand::DEFAULT_MIGRATION_TABLE) + ->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') ; } @@ -54,7 +54,7 @@ class MigrationUpCommand extends WrappedCommand return array( '--connection' => $this->getConnections($input->getOption('connection')), - '--migration-table' => $input->getOption('migration-table'), + '--migration-table' => $input->getOption('migration-table') ?: $this->getMigrationsTable(), '--output-dir' => $input->getOption('output-dir') ?: $defaultOutputDir, ); }