Use common function to update indexes

Needed as multiple objects could be modified in a transaction, e.g.,
cascade deletes.