summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-06-02 14:37:57 +0200
committerMorris Jobke <hey@morrisjobke.de>2017-07-05 13:01:19 +0200
commit8c39e66619852b8f2e4a9ca5a210970c6c2c619b (patch)
treed29beff36425117de617564c58f55947444d5929 /core
parent2875b79c614b40836b13e94f47805ba9f9f1bc65 (diff)
downloadnextcloud-server-8c39e66619852b8f2e4a9ca5a210970c6c2c619b.tar.gz
nextcloud-server-8c39e66619852b8f2e4a9ca5a210970c6c2c619b.zip
Do not allow to go back on productive systems
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core')
-rw-r--r--core/Command/Db/Migrations/ExecuteCommand.php24
-rw-r--r--core/register_command.php2
2 files changed, 24 insertions, 2 deletions
diff --git a/core/Command/Db/Migrations/ExecuteCommand.php b/core/Command/Db/Migrations/ExecuteCommand.php
index 6aad4f4973f..5eaecd06984 100644
--- a/core/Command/Db/Migrations/ExecuteCommand.php
+++ b/core/Command/Db/Migrations/ExecuteCommand.php
@@ -24,6 +24,7 @@ namespace OC\Core\Command\Db\Migrations;
use OC\DB\MigrationService;
use OC\Migration\ConsoleOutput;
+use OCP\IConfig;
use OCP\IDBConnection;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@@ -34,14 +35,18 @@ class ExecuteCommand extends Command {
/** @var IDBConnection */
private $connection;
+ /** @var IConfig */
+ private $config;
/**
* ExecuteCommand constructor.
*
* @param IDBConnection $connection
+ * @param IConfig $config
*/
- public function __construct(IDBConnection $connection) {
+ public function __construct(IDBConnection $connection, IConfig $config) {
$this->connection = $connection;
+ $this->config = $config;
parent::__construct();
}
@@ -56,12 +61,29 @@ class ExecuteCommand extends Command {
parent::configure();
}
+ /**
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ * @return int
+ */
public function execute(InputInterface $input, OutputInterface $output) {
$appName = $input->getArgument('app');
$ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
$version = $input->getArgument('version');
+ if ($this->config->getSystemValue('debug', false) === false) {
+ $olderVersions = $ms->getMigratedVersions();
+ $olderVersions[] = '0';
+ $olderVersions[] = 'prev';
+ if (in_array($version, $olderVersions, true)) {
+ $output->writeln('<error>Can not go back to previous migration without debug enabled</error>');
+ return 1;
+ }
+ }
+
+
$ms->executeStep($version);
+ return 0;
}
}
diff --git a/core/register_command.php b/core/register_command.php
index 924da6fc94f..bfb1138c5e3 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -88,7 +88,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
$application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getDatabaseConnection()));
$application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getDatabaseConnection()));
$application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection()));
- $application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->getDatabaseConnection()));
+ $application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager()));