Skip to content

Commit d9ff990

Browse files
Merge pull request #52394 from nextcloud/backport/51439/stable31
[stable31] fix(db): Create replacement index where original index is missing
2 parents a2979dc + 2dfda1e commit d9ff990

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

core/Command/Db/AddMissingIndices.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8686
if ($schema->hasTable($toReplaceIndex['tableName'])) {
8787
$table = $schema->getTable($toReplaceIndex['tableName']);
8888

89-
$allOldIndicesExists = true;
90-
foreach ($toReplaceIndex['oldIndexNames'] as $oldIndexName) {
91-
if (!$table->hasIndex($oldIndexName)) {
92-
$allOldIndicesExists = false;
93-
}
94-
}
95-
96-
if (!$allOldIndicesExists) {
89+
if ($table->hasIndex($toReplaceIndex['newIndexName'])) {
9790
continue;
9891
}
9992

@@ -110,8 +103,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
110103
}
111104

112105
foreach ($toReplaceIndex['oldIndexNames'] as $oldIndexName) {
113-
$output->writeln('<info>Removing ' . $oldIndexName . ' index from the ' . $table->getName() . ' table</info>');
114-
$table->dropIndex($oldIndexName);
106+
if ($table->hasIndex($oldIndexName)) {
107+
$output->writeln('<info>Removing ' . $oldIndexName . ' index from the ' . $table->getName() . ' table</info>');
108+
$table->dropIndex($oldIndexName);
109+
}
115110
}
116111

117112
if (!$dryRun) {

0 commit comments

Comments
 (0)