[libcommhistory] Update database indexes and add database upgrade path
[libcommhistory] Remove unused Group totalMessages and sentMessages fields

There are currently no users of these fields, and they are expensive to query
for every group.
[libcommhistory] Optimize groups query

This reduces the query time with 120,000 events from 7107ms to 1ms.