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
7 changes: 6 additions & 1 deletion lib/Migration/RepairSteps/CreateUniqueIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ public function run(IOutput $output): void {
// But the app relies on these indices to function properly, so we have to ensure they are created.
// If for any reasons the unique indices cannot be created, we remove all unique indices and create them again.
// This is a workaround for index conflicts that might occur during migration.
$output->warning('Polls - Exception during index migration: ' . $e->getMessage() . "\n" . $e->getTraceAsString());

if (str_contains($e->getMessage(), 'already exists') || str_contains($e->getMessage(), '42P07')) {
$output->warning('Polls - Index conflict detected, rebuilding unique indices: ' . $e->getMessage());
$output->warning('Polls - Index conflict detected, rebuilding unique indices.');
if ($this->connection->inTransaction()) {
$this->connection->rollBack();
}
$this->schema = $this->connection->createSchema();
$this->indexManager->setSchema($this->schema);
$messages = array_merge($messages, $this->indexManager->repairPrimaryKeys());
Expand Down
Loading