Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(db): Create replacement index where original index is missing
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst authored and backportbot[bot] committed Apr 23, 2025
commit 2dfda1ea26a5a6423040459759ff3a66f3efc401
15 changes: 5 additions & 10 deletions core/Command/Db/AddMissingIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
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;
}

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

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) {
Expand Down
Loading