Skip to content

Commit

Permalink
Merge pull request #5245 from nextcloud/backport/5242/stable20.1
Browse files Browse the repository at this point in the history
[stable20.1] Try to catch the unique constraint violation on migrating the data
  • Loading branch information
nickvergessen committed Mar 4, 2021
2 parents e1be5b1 + f56e55d commit bfc827a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/Migration/Version10000Date20201015134000.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit bfc827a

Please sign in to comment.