getTable('talk_attendees'); $table->addColumn('state', Types::SMALLINT, [ 'default' => 0, 'unsigned' => true, ]); $table->addColumn('unread_messages', Types::BIGINT, [ 'default' => 0, 'unsigned' => true, ]); $table = $schema->getTable('talk_rooms'); $table->addColumn('has_federation', Types::SMALLINT, [ 'default' => 0, 'unsigned' => true, ]); return $schema; } /** * Set the invitation state to accepted for existing federated users * Set the "has federation" for rooms with TalkV1 users */ #[\Override] public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { $query = $this->connection->getQueryBuilder(); $query->update('talk_attendees') ->set('state', $query->createNamedParameter(Invitation::STATE_ACCEPTED)) ->where($query->expr()->eq('actor_type', $query->createNamedParameter(Attendee::ACTOR_FEDERATED_USERS))); $query->executeStatement(); $query = $this->connection->getQueryBuilder(); $subQuery = $this->connection->getQueryBuilder(); $subQuery->select('room_id') ->from('talk_attendees') ->where($subQuery->expr()->eq('actor_type', $query->createNamedParameter(Attendee::ACTOR_FEDERATED_USERS))) ->groupBy('room_id'); $query = $this->connection->getQueryBuilder(); $query->update('talk_rooms') // Don't use const Room::HAS_FEDERATION_TALKv1 because the file might have been loaded with old content before the migration // ->set('has_federation', $query->createNamedParameter(Room::HAS_FEDERATION_TALKv1)) ->set('has_federation', $query->createNamedParameter(1)) ->where($query->expr()->in('id', $query->createFunction($subQuery->getSQL()))); $query->executeStatement(); } }