From 175392a2b630eb88f403ae9dc4cbe0d99f39d6f8 Mon Sep 17 00:00:00 2001 From: dartcafe Date: Mon, 27 Apr 2026 14:19:56 +0200 Subject: [PATCH 1/2] adding a rollback block before executing the exception code #4652 Signed-off-by: dartcafe --- lib/Migration/RepairSteps/CreateUniqueIndices.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Migration/RepairSteps/CreateUniqueIndices.php b/lib/Migration/RepairSteps/CreateUniqueIndices.php index af66131e2..39609c1d8 100644 --- a/lib/Migration/RepairSteps/CreateUniqueIndices.php +++ b/lib/Migration/RepairSteps/CreateUniqueIndices.php @@ -45,6 +45,9 @@ public function run(IOutput $output): void { // This is a workaround for index conflicts that might occur during migration. if (str_contains($e->getMessage(), 'already exists') || str_contains($e->getMessage(), '42P07')) { $output->warning('Polls - Index conflict detected, rebuilding unique indices: ' . $e->getMessage()); + if ($this->connection->inTransaction()) { + $this->connection->rollBack(); + } $this->schema = $this->connection->createSchema(); $this->indexManager->setSchema($this->schema); $messages = array_merge($messages, $this->indexManager->repairPrimaryKeys()); From 0119df2e3f2f987c79432d798e1803c3f62c204f Mon Sep 17 00:00:00 2001 From: dartcafe Date: Mon, 27 Apr 2026 19:21:20 +0200 Subject: [PATCH 2/2] move warning log Signed-off-by: dartcafe --- lib/Migration/RepairSteps/CreateUniqueIndices.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Migration/RepairSteps/CreateUniqueIndices.php b/lib/Migration/RepairSteps/CreateUniqueIndices.php index 39609c1d8..72708adc6 100644 --- a/lib/Migration/RepairSteps/CreateUniqueIndices.php +++ b/lib/Migration/RepairSteps/CreateUniqueIndices.php @@ -43,8 +43,10 @@ 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(); }