Merge Participants
The merging function combines duplicate Person records in the registration system due to duplicate registrations.
Merging needs to merge the relevant properties of the duplicate Person records, but also update foreign keys to the duplicate records to point to the new master Person record. This might include Participant and Result details.
Selecting a merge target
The merge target is the Person record which will become the new, single instance for the person.
The latest login record is considered the merge target, unless non are login records, in which case the latest non-login record is used.
The rational is that the latest record would typically contain the most up-to-date information.
Merging Person
The properties of the latest Person record will trump other conflicting properties. Properties not found in the latest, but in older records, will be copied over.
Merging Managed By
Owned records
All ManagedBy properties need to be moved to the new, target record, de-duplicating them if necessary.
Self references
ManagedBy properties need to be added any old login enabled records, as the person could still use them. So, the target record gets a ManagedBy record pointing to each of the old Person login record(s).
Other references
MangedBy properties on other Person records, not for the person being merged, pointing to the non-target Person, need to point to each of the login records of the merged person. This ensures that the merged person, no matter which login they use, can still manage the configured persons.
Other Persons: Pointing to login non-targets - Keep Add pointer(s) to all login records of Merged Person