From d0967b313f17a887afffb48ceb709b79df512cf5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 3 Jan 2018 15:08:19 +0100 Subject: [PATCH] Save more energy when installing This fixes the migrations for postgres, but the live code still errors. Signed-off-by: Joas Schilling --- lib/Migration/Version2001Date20170707115443.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Migration/Version2001Date20170707115443.php b/lib/Migration/Version2001Date20170707115443.php index 6b5cbd0eead..59c6fa4c859 100644 --- a/lib/Migration/Version2001Date20170707115443.php +++ b/lib/Migration/Version2001Date20170707115443.php @@ -84,6 +84,17 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { $query = $this->db->getQueryBuilder(); + $query->selectAlias($query->createFunction('COUNT(*)'), 'num_rooms') + ->from('spreedme_rooms'); + $result = $query->execute(); + $return = (int) $result->fetch(); + $result->closeCursor(); + $numRooms = (int) $return['num_rooms']; + + if ($numRooms === 0) { + return; + } + $query->select('id') ->from('spreedme_rooms') ->where($query->expr()->eq('type', $query->createNamedParameter(Room::ONE_TO_ONE_CALL))); @@ -100,8 +111,10 @@ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $output->info('Made ' . $owners . ' users owner of their one2one calls'); } - $moderators = $this->makeGroupParticipantsModerators($one2oneRooms); - $output->info('Made ' . $moderators . ' users moderators in group calls'); + if (count($one2oneRooms) !== $numRooms) { + $moderators = $this->makeGroupParticipantsModerators($one2oneRooms); + $output->info('Made ' . $moderators . ' users moderators in group calls'); + } } /**