Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-02-23 10:42:42 +0300
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-02-23 11:32:55 +0300
commit3de390097c8ad68f5f0b01af01297be38732bffe (patch)
tree6ef9fcd6f330bc1e34106502213e8ca0fcf4bb7e /lib
parent8e0e378a7d928e8447218931373625175a2ea5d1 (diff)
Try to catch the unique constraint violation on migrating the data
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Migration/Version10000Date20201015134000.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Migration/Version10000Date20201015134000.php b/lib/Migration/Version10000Date20201015134000.php
index b3e870f0f..0f95453af 100644
--- a/lib/Migration/Version10000Date20201015134000.php
+++ b/lib/Migration/Version10000Date20201015134000.php
@@ -26,10 +26,12 @@ declare(strict_types=1);
namespace OCA\Talk\Migration;
use Closure;
+use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\DBAL\Types\Types;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Participant;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\DB\Exception;
use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
@@ -220,7 +222,22 @@ class Version10000Date20201015134000 extends SimpleMigrationStep {
->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;
+ }
+
+ if (get_class($e) === Exception::class
+ // Exception with 21 and later
+ && $e->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
+ continue;
+ }
+
+ throw $e;
+ }
}
$result->closeCursor();
}