From bc6bc391a188aeaff5588f096ddf4146edeca706 Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Fri, 16 Apr 2010 19:22:37 -0400 Subject: [PATCH] Initial entry of new commands for migrations integration --- .../Command/MigrationsDiffDoctrineCommand.php | 50 +++++++++++++++++++ .../MigrationsExecuteDoctrineCommand.php | 49 ++++++++++++++++++ .../MigrationsGenerateDoctrineCommand.php | 49 ++++++++++++++++++ .../MigrationsMigrateDoctrineCommand.php | 49 ++++++++++++++++++ .../MigrationsStatusDoctrineCommand.php | 49 ++++++++++++++++++ .../MigrationsVersionDoctrineCommand.php | 46 +++++++++++++++++ 6 files changed, 292 insertions(+) create mode 100644 src/Symfony/Framework/DoctrineBundle/Command/MigrationsDiffDoctrineCommand.php create mode 100644 src/Symfony/Framework/DoctrineBundle/Command/MigrationsExecuteDoctrineCommand.php create mode 100644 src/Symfony/Framework/DoctrineBundle/Command/MigrationsGenerateDoctrineCommand.php create mode 100644 src/Symfony/Framework/DoctrineBundle/Command/MigrationsMigrateDoctrineCommand.php create mode 100644 src/Symfony/Framework/DoctrineBundle/Command/MigrationsStatusDoctrineCommand.php create mode 100644 src/Symfony/Framework/DoctrineBundle/Command/MigrationsVersionDoctrineCommand.php diff --git a/src/Symfony/Framework/DoctrineBundle/Command/MigrationsDiffDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/MigrationsDiffDoctrineCommand.php new file mode 100644 index 000000000000..7f38e088e09e --- /dev/null +++ b/src/Symfony/Framework/DoctrineBundle/Command/MigrationsDiffDoctrineCommand.php @@ -0,0 +1,50 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * Command for generate migration classes by comparing your current database schema + * to your mapping information. + * + * @package Symfony + * @subpackage Framework_DoctrineBundle + * @author Fabien Potencier + * @author Jonathan H. Wage + */ +class MigrationsDiffDoctrineCommand extends DiffCommand +{ + protected function configure() + { + parent::configure(); + + $this + ->setName('doctrine:migrations:diff') + ->addOption('bundle', null, InputOption::PARAMETER_REQUIRED, 'The bundle to load migrations configuration from.') + ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.') + ; + } + + public function execute(InputInterface $input, OutputInterface $output) + { + DoctrineCommand::setApplicationEntityManager($this->application, $input->getOption('em')); + + $configuration = $this->_getMigrationConfiguration($input, $output); + DoctrineCommand::configureMigrationsForBundle($this->application, $input->getOption('bundle'), $configuration); + + parent::execute($input, $output); + } +} \ No newline at end of file diff --git a/src/Symfony/Framework/DoctrineBundle/Command/MigrationsExecuteDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/MigrationsExecuteDoctrineCommand.php new file mode 100644 index 000000000000..a65d53ea9f78 --- /dev/null +++ b/src/Symfony/Framework/DoctrineBundle/Command/MigrationsExecuteDoctrineCommand.php @@ -0,0 +1,49 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * Command for executing single migrations up or down manually. + * + * @package Symfony + * @subpackage Framework_DoctrineBundle + * @author Fabien Potencier + * @author Jonathan H. Wage + */ +class MigrationsExecuteDoctrineCommand extends ExecuteCommand +{ + protected function configure() + { + parent::configure(); + + $this + ->setName('doctrine:migrations:execute') + ->addOption('bundle', null, InputOption::PARAMETER_REQUIRED, 'The bundle to load migrations configuration from.') + ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.') + ; + } + + public function execute(InputInterface $input, OutputInterface $output) + { + DoctrineCommand::setApplicationEntityManager($this->application, $input->getOption('em')); + + $configuration = $this->_getMigrationConfiguration($input, $output); + DoctrineCommand::configureMigrationsForBundle($this->application, $input->getOption('bundle'), $configuration); + + parent::execute($input, $output); + } +} \ No newline at end of file diff --git a/src/Symfony/Framework/DoctrineBundle/Command/MigrationsGenerateDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/MigrationsGenerateDoctrineCommand.php new file mode 100644 index 000000000000..a45c05c13c5e --- /dev/null +++ b/src/Symfony/Framework/DoctrineBundle/Command/MigrationsGenerateDoctrineCommand.php @@ -0,0 +1,49 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * Command for generating new blank migration classes + * + * @package Symfony + * @subpackage Framework_DoctrineBundle + * @author Fabien Potencier + * @author Jonathan H. Wage + */ +class MigrationsGenerateDoctrineCommand extends GenerateCommand +{ + protected function configure() + { + parent::configure(); + + $this + ->setName('doctrine:migrations:generate') + ->addOption('bundle', null, InputOption::PARAMETER_REQUIRED, 'The bundle to load migrations configuration from.') + ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.') + ; + } + + public function execute(InputInterface $input, OutputInterface $output) + { + DoctrineCommand::setApplicationEntityManager($this->application, $input->getOption('em')); + + $configuration = $this->_getMigrationConfiguration($input, $output); + DoctrineCommand::configureMigrationsForBundle($this->application, $input->getOption('bundle'), $configuration); + + parent::execute($input, $output); + } +} \ No newline at end of file diff --git a/src/Symfony/Framework/DoctrineBundle/Command/MigrationsMigrateDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/MigrationsMigrateDoctrineCommand.php new file mode 100644 index 000000000000..6235c88defd6 --- /dev/null +++ b/src/Symfony/Framework/DoctrineBundle/Command/MigrationsMigrateDoctrineCommand.php @@ -0,0 +1,49 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * Command for executing a migration to a specified version or the latest available version. + * + * @package Symfony + * @subpackage Framework_DoctrineBundle + * @author Fabien Potencier + * @author Jonathan H. Wage + */ +class MigrationsMigrateDoctrineCommand extends MigrateCommand +{ + protected function configure() + { + parent::configure(); + + $this + ->setName('doctrine:migrations:migrate') + ->addOption('bundle', null, InputOption::PARAMETER_REQUIRED, 'The bundle to load migrations configuration from.') + ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.') + ; + } + + public function execute(InputInterface $input, OutputInterface $output) + { + DoctrineCommand::setApplicationEntityManager($this->application, $input->getOption('em')); + + $configuration = $this->_getMigrationConfiguration($input, $output); + DoctrineCommand::configureMigrationsForBundle($this->application, $input->getOption('bundle'), $configuration); + + parent::execute($input, $output); + } +} \ No newline at end of file diff --git a/src/Symfony/Framework/DoctrineBundle/Command/MigrationsStatusDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/MigrationsStatusDoctrineCommand.php new file mode 100644 index 000000000000..19122b5b246e --- /dev/null +++ b/src/Symfony/Framework/DoctrineBundle/Command/MigrationsStatusDoctrineCommand.php @@ -0,0 +1,49 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * Command to view the status of a set of migrations. + * + * @package Symfony + * @subpackage Framework_DoctrineBundle + * @author Fabien Potencier + * @author Jonathan H. Wage + */ +class MigrationsStatusDoctrineCommand extends StatusCommand +{ + protected function configure() + { + parent::configure(); + + $this + ->setName('doctrine:migrations:status') + ->addOption('bundle', null, InputOption::PARAMETER_REQUIRED, 'The bundle to load migrations configuration from.') + ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.') + ; + } + + public function execute(InputInterface $input, OutputInterface $output) + { + DoctrineCommand::setApplicationEntityManager($this->application, $input->getOption('em')); + + $configuration = $this->_getMigrationConfiguration($input, $output); + DoctrineCommand::configureMigrationsForBundle($this->application, $input->getOption('bundle'), $configuration); + + parent::execute($input, $output); + } +} \ No newline at end of file diff --git a/src/Symfony/Framework/DoctrineBundle/Command/MigrationsVersionDoctrineCommand.php b/src/Symfony/Framework/DoctrineBundle/Command/MigrationsVersionDoctrineCommand.php new file mode 100644 index 000000000000..89b3ed3abd42 --- /dev/null +++ b/src/Symfony/Framework/DoctrineBundle/Command/MigrationsVersionDoctrineCommand.php @@ -0,0 +1,46 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * Command for manually adding and deleting migration versions from the version table. + * + * @package Symfony + * @subpackage Framework_DoctrineBundle + * @author Fabien Potencier + * @author Jonathan H. Wage + */ +class MigrationsVersionDoctrineCommand extends VersionCommand +{ + protected function configure() + { + parent::configure(); + + $this + ->setName('doctrine:migrations:version') + ->addOption('bundle', null, InputOption::PARAMETER_REQUIRED, 'The bundle to load migrations configuration from.') + ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.') + ; + } + + public function execute(InputInterface $input, OutputInterface $output) + { + DoctrineCommand::setApplicationEntityManager($this->application, $input->getOption('em')); + + parent::execute($input, $output); + } +} \ No newline at end of file