Wrap reordering in a database transaction

this ensures that if two people try to reorder the same attachments at
the same time, only one set of orderings will be persisted and a
consistent state will remain, rather than possibly two sets of orderings
being confounded and an inconsistent state remaining.