From a41f75ddfe91e2da353caa2fcf6afba7b5ee2ca6 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Mon, 15 Mar 2010 22:43:16 -0700 Subject: 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 --- Bugzilla/DB.pm | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index 830d2835e..85ad77e17 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -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 @dropped; + my @related; 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 { -- cgit v1.2.3-24-g4f1b