[Mediawiki-l] Merging two Users into one user(-account)

Jan 2036 at gmx.de
Fri Dec 29 21:56:22 UTC 2006


Hello!

I want to merge two user-accounts on my wiki (currently 1.6.8, will be updated 
in februar to 1.9.x).

I searched in archives of this list, and found a description by
Michael Richards from 10/2004. I dont now, which version he describes, but afaik 
the DB-layout has changed. I have quoted the old description from 2004 below.

Is there any extension to merge user-accounts?
Or could anyone give me the current (updated) SQL-Statements to merge to 
user-accounts?

Best regards ... and a happy New Year,
Jan


-----------------------------
Citation from archiv:

Richards,Michael Michael.Richards at gartner.com
Mon Oct 4 20:11:15 UTC 2004

Chuck,
First, find the user_id for the account you wish to delete e.g.
    select user_id from user where user_name = 'old_user_name';

Assuming they have no contributions, you can just delete the user record. e.g.
    delete from user where user_name = 'old_user_name';

However, if the reason you are deleting is because you have two user accounts 
for the same person, and the old user account has already been used to make 
edits, and you want to merge the two accounts, you also need to fix several 
other tables to point to the new username e.g. lets say the old user_id is 66, 
and the new user_id is 99:
   update old           set old_user_text = 'old_user_name' where old_user = 66;
   update cur           set cur_user_text = 'old_user_name' where cur_user = 66;
   update recentchanges set rc_user_text  = 'old_user_name' where rc_user  = 66;
   update archive       set ar_user_text  = 'old_user_name' where ar_user  = 66;
   update image         set img_user_text = 'old_user_name' where img_user = 66;
   update old           set old_user      = 99              where old_user = 66;
   update cur           set cur_user      = 99              where cur_user = 66;
   update recentchanges set rc_user       = 99              where rc_user  = 66;
   update archive       set ar_user       = 99              where ar_user  = 66;
   update image         set img_user      = 99              where img_user = 66;

Note that the user_id and user_name fields are duplicated in each of these five 
tables (for performance reasons).

There may be a script to do all this that I am unaware of. If so can someone 
please mention it.

If you just want to change the user name, then just update the user_name on the 
user table and the user_text on the other five tables. Again, there may be a 
script for this.

Michael Richards



More information about the MediaWiki-l mailing list