Optimize group query SQL

This series of changes:

1. Adds an upgrade path for databases, and changes some indexes on the Events table
2. Removes the 'totalMessages' and 'sentMessages' fields of Group entirely, including all relevant API. These seem to have no uses outside of libcommhistory itself, and are expensive to query for every group unconditionally
3. Tweaks the group query to avoid braindead choices by SQLite's query planner

For GroupModel::getGroups with 160 groups and 120k events, this reduces query time from 7500ms to <1ms.