From 21d6f17ff34a39ca24680f3f86cdaa56dcc97f89 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Wed, 17 Apr 2024 12:30:46 -0300 Subject: [PATCH] fix: Prevent exception when migration already was applied Signed-off-by: Vitor Mattos --- .../Version8000Date20231102215331.php | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/Migration/Version8000Date20231102215331.php b/lib/Migration/Version8000Date20231102215331.php index 6a37f2ac39..4a26bc72cc 100644 --- a/lib/Migration/Version8000Date20231102215331.php +++ b/lib/Migration/Version8000Date20231102215331.php @@ -27,6 +27,7 @@ namespace OCA\Libresign\Migration; use Closure; +use OC\DB\Exceptions\DbalException; use OCP\DB\ISchemaWrapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\Types; @@ -151,14 +152,20 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array } $cursor->closeCursor(); - $qb = $this->connection->getQueryBuilder(); - $qb->update('libresign_file_element') - ->set('sign_request_id', 'file_user_id') - ->executeStatement(); + try { + $qb = $this->connection->getQueryBuilder(); + $qb->update('libresign_file_element') + ->set('sign_request_id', 'file_user_id') + ->executeStatement(); + } catch (DbalException $e) { + } - $qb = $this->connection->getQueryBuilder(); - $qb->update('libresign_identify_method') - ->set('sign_request_id', 'file_user_id') - ->executeStatement(); + try { + $qb = $this->connection->getQueryBuilder(); + $qb->update('libresign_identify_method') + ->set('sign_request_id', 'file_user_id') + ->executeStatement(); + } catch (DbalException $e) { + } } }