Hello,
I'm developing a set of modules for a large association. Because of the way our stuff has to work, we tend to end up with a number of problematic duplicate accounts. So, a user will have accounts under the names "jphillips" and "phillips" and "johnp" or whatever. I need a way to merge these accounts. Obviously, this is problematic in many ways, so, I am hoping somebody can help review my logic here or provide some insights. Obviously, in a big open system like DNN this is going to be hard and messy...
My thought is to follow these basic steps:
- Make a module to manage duplicates and duplicate resolution
- Add a hidden profile field that's "Merged to User ID"
- make an "IDuplicateResolver" interface that lets me tell some sub-set of my modules that a two accounts should be merged. Here, our "membership" system would get a request that basically says "merge jphillips and phillips". Then, it will go through all of it's membership records and change jphillip's user ID to use phillip's user ID.
- Implement that interface in every sub-area of my modules and implement a general one for the core
- Performing the merge:
- Call my core duplicate controller to change every instance of UserID (a) to UserID (b) in all core tables
- Call a similar extended controller to look for common modules and change those UserIDs
- Change User a's "Merged to User ID" profile field to be the UserID of user b
- Delete user A
- Log the action in my duplicate management tables
I know this is going to be messy... I am aware of these challenges:
- Many changes are impossible through the API - so, I'll need a very big and complicated db procedure
- Some modules may use usernames instead of user IDs
- Some modules/tables may have restrictions against two records becoming tagged to the same person. For example, maybe some "events" modules won't let you have the same user on the same event twice. Normally, this wouldn't happen, but, if both of my duplicate accounts were on that event, my duplicate resolution system would force it to happen.
- Logging the changes is very difficult when this is done at the table level.
Because I am only soft-deleting the old accounts, I don't think it's the end of the world if I miss some entries. I really just need to make sure security roles and my own stuff transfers.
On a side note, this process does have me thinking a bit about a core change though... I feel like duplicate resolution would be a great feature to have on modules - just like searchable or exportable. In the tables, it's really just a matter of changing UserIDs whatnot to the other user.
Anyway - does anybody have any tips or anything I should watch for here?
Thanks,
Mike