aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/Db/AddMissingIndices.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/Db/AddMissingIndices.php')
-rw-r--r--core/Command/Db/AddMissingIndices.php46
1 files changed, 8 insertions, 38 deletions
diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php
index 1e10b6152ce..eec0aedce11 100644
--- a/core/Command/Db/AddMissingIndices.php
+++ b/core/Command/Db/AddMissingIndices.php
@@ -3,33 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
- *
- * @author Bjoern Schiessle <bjoern@schiessle.org>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Mario Danic <mario@lovelyhq.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Citharel <nextcloud@tcit.fr>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Core\Command\Db;
@@ -62,7 +37,7 @@ class AddMissingIndices extends Command {
$this
->setName('db:add-missing-indices')
->setDescription('Add missing indices to the database tables')
- ->addOption('dry-run', null, InputOption::VALUE_NONE, "Output the SQL queries instead of running them.");
+ ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Output the SQL queries instead of running them.');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
@@ -111,14 +86,7 @@ class AddMissingIndices extends Command {
if ($schema->hasTable($toReplaceIndex['tableName'])) {
$table = $schema->getTable($toReplaceIndex['tableName']);
- $allOldIndicesExists = true;
- foreach ($toReplaceIndex['oldIndexNames'] as $oldIndexName) {
- if (!$table->hasIndex($oldIndexName)) {
- $allOldIndicesExists = false;
- }
- }
-
- if (!$allOldIndicesExists) {
+ if ($table->hasIndex($toReplaceIndex['newIndexName'])) {
continue;
}
@@ -135,8 +103,10 @@ class AddMissingIndices extends Command {
}
foreach ($toReplaceIndex['oldIndexNames'] as $oldIndexName) {
- $output->writeln('<info>Removing ' . $oldIndexName . ' index from the ' . $table->getName() . ' table</info>');
- $table->dropIndex($oldIndexName);
+ if ($table->hasIndex($oldIndexName)) {
+ $output->writeln('<info>Removing ' . $oldIndexName . ' index from the ' . $table->getName() . ' table</info>');
+ $table->dropIndex($oldIndexName);
+ }
}
if (!$dryRun) {