From f56e55dcf035332b482531fad82bc976ae774172 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 23 Feb 2021 08:42:42 +0100 Subject: [PATCH] Try to catch the unique constraint violation on migrating the data Signed-off-by: Joas Schilling --- lib/Migration/Version10000Date20201015134000.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Migration/Version10000Date20201015134000.php b/lib/Migration/Version10000Date20201015134000.php index aa7e5bb5e00..cc5fdc7f3d9 100644 --- a/lib/Migration/Version10000Date20201015134000.php +++ b/lib/Migration/Version10000Date20201015134000.php @@ -26,6 +26,7 @@ namespace OCA\Talk\Migration; use Closure; +use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Doctrine\DBAL\Types\Type; use OCA\Talk\Model\Attendee; use OCA\Talk\Participant; @@ -220,7 +221,16 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array ->setParameter('last_mention_message', (int) $row['last_mention_message'], IQueryBuilder::PARAM_INT) ; - $insert->execute(); + try { + $insert->execute(); + } catch (\Exception $e) { + if (get_class($e) === UniqueConstraintViolationException::class) { + // UniqueConstraintViolationException before 21 + continue; + } + + throw $e; + } } $result->closeCursor(); }