Closed Bug 188264 Opened 22 years ago Closed 18 years ago

migrating user activity from one account to another (merge user accounts)

Categories

(Bugzilla :: Bugzilla-General, enhancement)

2.20
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 2.20

People

(Reporter: myk, Assigned: LpSolit)

References

Details

Attachments

(2 files, 5 obsolete files)

In rare cases it may be useful to migrate user activity from one account to
another.  A script for doing this would be useful.
Attached file script to do the job (obsolete) —
This script does the job with a caveat: updates that attempt to insert
duplicate keys into tables will fail.
Is this anything like bug 112317?
Almost, except I think in this case the two accounts should remain independent;
just the activity should be migrated.  Bug 112317 calls for one account to cease
to exist afterwards.  On the other hand, maybe this is what should happen in
this case too.
I was assuming my old account would cease to exist afterwards.  Seems like it
ought to so that people can't inadvertantly CC or assign to it.
I don't like this sort of stuff as a matter of principle. Does it really matter
that you hve two accounts?

You need to delete from teh profiles table, too.
Attachment #111006 - Attachment is obsolete: true
*** Bug 112317 has been marked as a duplicate of this bug. ***
Attached file script v3: bug fixes (obsolete) —
This version correctly merges all user_group_map records.  I call this script
merge-users.pl and run it from the Bugzilla root directory.  Note that it works
with the schema in effect on Tue Nov 19 01:12:48 PST 2002, which may or may not
be the same one on the trunk.
Attachment #111091 - Attachment is obsolete: true
Notes:

1. I ran this script on b.m.o about 15 minutes ago as "./merge-users.pl
dmose@meer.net dmose@mozilla.org".

2. If Bugzilla is shut down the script erroneously reports that it can't find
the old user (i.e. the first one in the list, whose profiles table settings are
deleted in preference to the "new" user, or the second one in the list).
That's because if Bugzilla is shut down, SendSQL won't send quieries to the
database unless they are coming from editparams.cgi
Summary: migrating user activity from one account to another → migrating user activity from one account to another (merge user accounts)
We should tidy this up and work it into editusers.cgi
Target Milestone: --- → Bugzilla 2.22
I've updated the script to work with the 2.19.2 schema and database API.  I
guarantee you that it won't work in 2.19.3 because there's been yet more schema
and API changes.  Changes in this version from the previous include migrating
chart series, and the changes in the definition to the user_group_map table.
Assignee: myk → justdave
Attachment #111216 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Reassigning bugs that I'm not actively working on to the default component owner
in order to try to make some sanity out of my personal buglist.  This doesn't
mean the bug isn't being dealt with, just that I'm not the one doing it.  If you
are dealing with this bug, please assign it to yourself.
Assignee: justdave → general
Status: ASSIGNED → NEW
QA Contact: mattyt-bugzilla → default-qa
This is still mine.
Assignee: general → justdave
The trunk is now frozen to prepare Bugzilla 2.22. Enhancement bugs are retargetted to 2.24.
Target Milestone: Bugzilla 2.22 → Bugzilla 2.24
*** Bug 317902 has been marked as a duplicate of this bug. ***
Attached file merge-users.pl compatible with 2.20+ (obsolete) —
Attachment #207319 - Flags: review?(justdave)
slight improvement:

don't go further if both accounts are identical.
Attachment #207319 - Attachment is obsolete: true
Attachment #207388 - Flags: review?(justdave)
Attachment #207319 - Flags: review?(justdave)
Comment on attachment 207388 [details]
merge-users.pl compatible with 2.20+, v2

  I think the script should print out its usage instead of having it in the comments.

># We require Bugzilla 2.20 - 2.20.x.
>my $expected_version = "2.20";
>my $current_version = $Bugzilla::Config::VERSION;
>if ($current_version =~ /^\Q$expected_version\E/) {
>    print "OK, you are using Bugzilla $current_version\n"
>}
>else {
>    die "You are using Bugzilla $current_version but Bugzilla " .
>        "$expected_version.x is required.\n";
>}

  I don't think that this is really necessary. At the least, it's just going to be a pain to keep it updated on various branches in the future.

># Make sure the old and new accounts are different.
>if ($old_id = $new_id) {
>    die "\nBoth accounts are identical. There is nothing to migrate.\n";
>}

  That should be "==" I believe.

># A list of tables and columns to be changed:
># - keys of the hash are table names to be locked/altered;
># - values of the hash are arrays of column lists to be updated:
>#   = the first name of the list is the column to update,
>#   = the remaining names are the columns to check to avoid duplicated entries.

  I think you should explain what you mean by "first name of the list" and "remaining names of the list." I remember that you had to explain to me how the script actually works; I didn't fully understand it just from the comments.

>        # Will be used to migrate the old user account to the new one.
>        my $sth_Update = $dbh->prepare("UPDATE $table

  Nit: Having that "Update" be capitalized violates perlstyle. Same for the "Delete" one later.

  Everything else looks fine. I know that this works since we used it for a client.
Attachment #207388 - Flags: review?(justdave) → review-
Fixes all comments, except the version check as discussed on IRC.
Attachment #207388 - Attachment is obsolete: true
Attachment #208157 - Flags: review?(mkanat)
Comment on attachment 208157 [details]
merge-users.pl compatible with 2.20+, v3

Okay, I know that this works on 2.20. Could you also post a version for 2.22 and the tip?
Attachment #208157 - Flags: review?(mkanat) → review+
This is just a contrib script, and I *know* it works on the branch, so I don't see any reason not to check it in to the branches.
Assignee: justdave → LpSolit
Target Milestone: Bugzilla 2.24 → Bugzilla 2.20
Version: unspecified → 2.20
AFAIK, the schema didn't change between 2.20 and 2.22 (and even 2.23 so far) about userid. And my patch already accepts 2.22 as a valid Bugzilla version. I can make it accept 2.23 as well on checkin.
Status: NEW → ASSIGNED
Flags: approval?
Flags: approval2.22?
Flags: approval2.20?
hell yes. :)
Flags: approval?
Flags: approval2.22?
Flags: approval2.22+
Flags: approval2.20?
Flags: approval2.20+
Flags: approval+
tip:

Checking in contrib/merge-users.pl;
/cvsroot/mozilla/webtools/bugzilla/contrib/merge-users.pl,v  <--  merge-users.pl
initial revision: 1.1
done

2.22rc1:

Checking in contrib/merge-users.pl;
/cvsroot/mozilla/webtools/bugzilla/contrib/merge-users.pl,v  <--  merge-users.pl
new revision: 1.1.2.2; previous revision: 1.1.2.1
done

2.20.1:

Checking in contrib/merge-users.pl;
/cvsroot/mozilla/webtools/bugzilla/contrib/merge-users.pl,v  <--  merge-users.pl
new revision: 1.1.4.2; previous revision: 1.1.4.1
done
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: