Skip to content

Commit

Permalink
Try to catch the unique constraint violation on migrating the data
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Mar 4, 2021
1 parent 2f89a35 commit f56e55d
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 f56e55d

Please sign in to comment.