Fix migration restoreReferencesOrder removes references

The restoreReferencesOrder iterates over all UIDs in obj._relatedItems
to recreate obj.relatedItems. That way the references from obj._backrefs
are removed.

The fix removes restoreReferencesOrder and adds a beforeChange_relatedItemsOrder
method to fhe ReferenceMigratror class. That method stores Archetype relations as
target uids on the old archetype object to restore the order later.
Because all relations to deleted objects will be lost, we iterate
over all backref objects and store the relations of the backref
object in advance.