Skip to content

Commit

Permalink
Save more energy when installing
Browse files Browse the repository at this point in the history
This fixes the migrations for postgres, but the live code still errors.

Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jan 3, 2018
1 parent 9b51df8 commit d0967b3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/Migration/Version2001Date20170707115443.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand All @@ -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');
}
}

/**
Expand Down

0 comments on commit d0967b3

Please sign in to comment.