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
On 29/12/06, Jan 2036@gmx.de wrote:
Is there any extension to merge user-accounts? Or could anyone give me the current (updated) SQL-Statements to merge to user-accounts?
To do all the base stuff:
UPDATE archive SET ar_user = $nid, ar_user_text = $nun WHERE ar_user = $oid UPDATE filearchive SET fa_user = $nid, fa_user_text = $nun WHERE fa_user = $oid UPDATE image SET img_user = $nid, img_user_text = $nun WHERE img_user = $oid UPDATE logging SET log_user = $nid WHERE log_user = $oid UPDATE oldimage SET oi_user = $nid, oi_user_text = $nun WHERE oi_user = $oid UPDATE recentchanges SET rc_user = $nid, rc_user_text = $nun WHERE rc_user = $oid UPDATE revision SET rev_user = $nid, rev_user_text = $nun WHERE rev_user = $oid
To move watchlist items too:
UPDATE watchlist SET wl_user = $nid WHERE wl_user = $oid
To move groups:
UPDATE user_groups SET ug_user = $nid WHERE ug_user = $oid
All the above assume that $nid is the user_id of the destination user, $nun is the user_name of the destination user, and $oid is the user_id of the user account which will not be used.
This will not delete the accounts; you could theoretically remove the corresponding user table row, and have the old user and talk pages redirect to the new ones (avoid breaking signatures on existing pages), but that's at your own risk.
As ever, when messing about with the database in a major fashion, make a backup.
Rob Church
Thanks Rob :) To be sure: For which versions of MW (DB-layout) your statements will work? 1.6.x to current 1.9svn ?
regards, jan
Rob Church schrieb:
On 29/12/06, Jan 2036@gmx.de wrote:
Is there any extension to merge user-accounts? Or could anyone give me the current (updated) SQL-Statements to merge to user-accounts?
To do all the base stuff:
UPDATE archive SET ar_user = $nid, ar_user_text = $nun WHERE ar_user = $oid UPDATE filearchive SET fa_user = $nid, fa_user_text = $nun WHERE fa_user = $oid UPDATE image SET img_user = $nid, img_user_text = $nun WHERE img_user = $oid UPDATE logging SET log_user = $nid WHERE log_user = $oid UPDATE oldimage SET oi_user = $nid, oi_user_text = $nun WHERE oi_user = $oid UPDATE recentchanges SET rc_user = $nid, rc_user_text = $nun WHERE rc_user = $oid UPDATE revision SET rev_user = $nid, rev_user_text = $nun WHERE rev_user = $oid
To move watchlist items too:
UPDATE watchlist SET wl_user = $nid WHERE wl_user = $oid
To move groups:
UPDATE user_groups SET ug_user = $nid WHERE ug_user = $oid
All the above assume that $nid is the user_id of the destination user, $nun is the user_name of the destination user, and $oid is the user_id of the user account which will not be used.
This will not delete the accounts; you could theoretically remove the corresponding user table row, and have the old user and talk pages redirect to the new ones (avoid breaking signatures on existing pages), but that's at your own risk.
As ever, when messing about with the database in a major fashion, make a backup.
Rob Church _______________________________________________ MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
On 31/12/06, Jan 2036@gmx.de wrote:
Thanks Rob :) To be sure: For which versions of MW (DB-layout) your statements will work? 1.6.x to current 1.9svn ?
Should cover 1.7.0 through to (and including) 1.9alpha. Check the database and omit statements for tables which don't exist.
Rob Church
mediawiki-l@lists.wikimedia.org