Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
a41f75dd
Commit
a41f75dd
authored
Mar 15, 2010
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 545770: Make contrib/merge-users.pl figure out what columns to merge
by tracing FKs instead of having a fixed list. r=LpSolit, a=LpSolit
parent
0ee52e9d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
24 deletions
+32
-24
DB.pm
Bugzilla/DB.pm
+14
-5
merge-users.pl
contrib/merge-users.pl
+18
-19
No files found.
Bugzilla/DB.pm
View file @
a41f75dd
...
...
@@ -754,10 +754,10 @@ sub bz_drop_fk {
}
sub
bz_
drop
_related_fks
{
sub
bz_
get
_related_fks
{
my
(
$self
,
$table
,
$column
)
=
@_
;
my
@tables
=
$self
->
_bz_real_schema
->
get_table_list
();
my
@
dropp
ed
;
my
@
relat
ed
;
foreach
my
$check_table
(
@tables
)
{
my
@columns
=
$self
->
bz_table_columns
(
$check_table
);
foreach
my
$check_column
(
@columns
)
{
...
...
@@ -767,13 +767,22 @@ sub bz_drop_related_fks {
and
((
$fk
->
{
TABLE
}
eq
$table
and
$fk
->
{
COLUMN
}
eq
$column
)
or
(
$check_column
eq
$column
and
$check_table
eq
$table
)))
{
$self
->
bz_drop_fk
(
$check_table
,
$check_column
);
push
(
@dropped
,
[
$check_table
,
$check_column
,
$fk
]);
push
(
@related
,
[
$check_table
,
$check_column
,
$fk
]);
}
}
# foreach $column
}
# foreach $table
return
\
@dropped
;
return
\
@related
;
}
sub
bz_drop_related_fks
{
my
$self
=
shift
;
my
$related
=
$self
->
bz_get_related_fks
(
@_
);
foreach
my
$item
(
@$related
)
{
my
(
$table
,
$column
)
=
@$item
;
$self
->
bz_drop_fk
(
$table
,
$column
);
}
return
$related
;
}
sub
bz_drop_index
{
...
...
contrib/merge-users.pl
View file @
a41f75dd
...
...
@@ -121,20 +121,13 @@ if ($old_id == $new_id) {
# where fooN is the column to update, and barN1, barN2, ... are
# the columns to take into account to avoid duplicated entries.
# Note that the barNM columns are optional.
my
$changes
=
{
# Tables affecting bugs.
bugs
=>
[
'assigned_to'
,
'reporter'
,
'qa_contact'
],
bugs_activity
=>
[
'who'
],
attachments
=>
[
'submitter_id'
],
flags
=>
[
'setter_id'
,
'requestee_id'
],
#
# We set the tables that require custom stuff (multiple columns to check)
# here, but the simple stuff is all handled below by bz_get_related_fks.
my
%
changes
=
(
cc
=>
[
'who bug_id'
],
longdescs
=>
[
'who'
],
# Tables affecting global behavior / other users.
components
=>
[
'initialowner'
,
'initialqacontact'
],
component_cc
=>
[
'user_id component_id'
],
quips
=>
[
'userid'
],
series
=>
[
'creator'
],
whine_events
=>
[
'owner_userid'
],
watch
=>
[
'watcher watched'
,
'watched watcher'
],
# Tables affecting the user directly.
namedqueries
=>
[
'userid name'
],
...
...
@@ -142,17 +135,23 @@ my $changes = {
user_group_map
=>
[
'user_id group_id isbless grant_type'
],
email_setting
=>
[
'user_id relationship event'
],
profile_setting
=>
[
'user_id setting_name'
],
profiles_activity
=>
[
'userid'
,
'who'
],
# Should activity be migrated?
# Only do it if mailto_type = 0, i.e is pointing to a user account!
# This requires to be done separately due to this condition.
whine_schedules
=>
[]
,
# ['mailto'],
);
my
$userid_fks
=
$dbh
->
bz_get_related_fks
(
'profiles'
,
'userid'
);
foreach
my
$item
(
@$userid_fks
)
{
my
(
$table
,
$column
)
=
@$item
;
$changes
{
$table
}
||=
[]
;
push
(
@
{
$changes
{
$table
}
},
$column
);
}
# Delete all old records for these tables; no migration.
logincookies
=>
[]
,
# ['userid'],
tokens
=>
[]
,
# ['userid'],
profiles
=>
[]
,
# ['userid'],
};
# Delete all old records for these tables; no migration.
foreach
my
$table
(
qw(logincookies tokens profiles)
)
{
$changes
{
$table
}
=
[]
;
}
# Start the transaction
$dbh
->
bz_start_transaction
();
...
...
@@ -162,8 +161,8 @@ $dbh->do('DELETE FROM logincookies WHERE userid = ?', undef, $old_id);
$dbh
->
do
(
'DELETE FROM tokens WHERE userid = ?'
,
undef
,
$old_id
);
# Migrate records from old user to new user.
foreach
my
$table
(
keys
(
%
$changes
)
)
{
foreach
my
$column_list
(
@
{
$changes
->
{
$table
}
})
{
foreach
my
$table
(
keys
%
changes
)
{
foreach
my
$column_list
(
@
{
$changes
{
$table
}
})
{
# Get all columns to consider. There is always at least
# one column given: the one to update.
my
@columns
=
split
(
/[\s]+/
,
$column_list
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment