Merge pull request #51439 from nextcloud/fix/create-missing-replacement-indexes

fix(db): Create replacement index where original index is missing
ci/49145/php-8.4-external-storages
Andy Scherzinger 2025-04-24 00:49:22 +07:00 committed by GitHub
commit 2c8c036bdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 10 deletions

@ -86,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;
}
@ -110,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) {