fix(db): Create replacement index where original index is missing

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
pull/52394/head
Christoph Wurst 2025-03-12 13:05:37 +07:00 committed by backportbot[bot]
parent b41ba29d19
commit 2dfda1ea26
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) {