diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-06-05 16:19:24 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-06-06 10:11:14 +0200 |
commit | 5e27ac3e0d99c272dfb1c50cf7265cd8e329558c (patch) | |
tree | e445ba9b6fd7a0b7d383b704fd68d37d254975e7 /core/command/upgrade.php | |
parent | ff651a3e0d764e72ec3146c0163c80b3a872a05a (diff) | |
download | nextcloud-server-5e27ac3e0d99c272dfb1c50cf7265cd8e329558c.tar.gz nextcloud-server-5e27ac3e0d99c272dfb1c50cf7265cd8e329558c.zip |
Added CLI arguments for upgrade simulation steps
Added "dry run" argument to only run the update simulation.
Added argument to disable migration (useful for bigger setups where
table duplication would take too much space)
Diffstat (limited to 'core/command/upgrade.php')
-rw-r--r-- | core/command/upgrade.php | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/core/command/upgrade.php b/core/command/upgrade.php index c3946d2aab5..d037082c5e8 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -12,6 +12,7 @@ use OC\Updater; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputOption; class Upgrade extends Command { @@ -19,12 +20,24 @@ class Upgrade extends Command { const ERROR_NOT_INSTALLED = 1; const ERROR_MAINTENANCE_MODE = 2; const ERROR_UP_TO_DATE = 3; + const ERROR_INVALID_ARGUMENTS = 4; protected function configure() { $this ->setName('upgrade') ->setDescription('run upgrade routines') - ; + ->addOption( + '--skip-migration-test', + null, + InputOption::VALUE_NONE, + 'skips the database schema migration simulation and update directly' + ) + ->addOption( + '--dry-run', + null, + InputOption::VALUE_NONE, + 'only runs the database schema migration simulation, do not actually update' + ); } /** @@ -43,15 +56,41 @@ class Upgrade extends Command { return self::ERROR_NOT_INSTALLED; } + $simulateStepEnabled = true; + $updateStepEnabled = true; + + if ($input->getOption('skip-migration-test')) { + $simulateStepEnabled = false; + } + if ($input->getOption('dry-run')) { + $updateStepEnabled = false; + } + + if (!$simulateStepEnabled && !$updateStepEnabled) { + $output->writeln( + '<error>Only one of "--skip-migration-test" or "--dry-run" ' . + 'can be specified at a time.</error>' + ); + return self::ERROR_INVALID_ARGUMENTS; + } + if(\OC::checkUpgrade(false)) { $updater = new Updater(); + $updater->setSimulateStepEnabled($simulateStepEnabled); + $updater->setUpdateStepEnabled($updateStepEnabled); + $updater->listen('\OC\Updater', 'maintenanceStart', function () use($output) { $output->writeln('<info>Turned on maintenance mode</info>'); }); - $updater->listen('\OC\Updater', 'maintenanceEnd', function () use($output) { + $updater->listen('\OC\Updater', 'maintenanceEnd', function () use($output, $updateStepEnabled) { $output->writeln('<info>Turned off maintenance mode</info>'); - $output->writeln('<info>Update successful</info>'); + if (!$updateStepEnabled) { + $output->writeln('<info>Update simulation successful</info>'); + } + else { + $output->writeln('<info>Update successful</info>'); + } }); $updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) { $output->writeln('<info>Updated database</info>'); |