See PHI842. Ref T13195. If we discover commits have been removed from the repository, we rebuild the entire summary table.
This currently uses a query with two MAX(...) fields on different columns, and an importStatus & flag which can't be satisfied with a key.
Instead:
- Denormalize unreachability into a separate, keyable column.
- Add appropriate keys.
- Execute the query as two halves with UNION ALL.
Also, remove an ancient rebuild_summaries.php script which has a copy of this logic and isn't referenced anywhere. This should become bin/repository <something> if we have some need for it. It currently gets the wrong result (it isn't aware of unreachable commits).