diff options
author | mkanat%bugzilla.org <> | 2007-04-19 19:59:37 +0200 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2007-04-19 19:59:37 +0200 |
commit | d4e9172ad5f59d882ff372aff2cadd2c8c7f1ed3 (patch) | |
tree | 0ea78337de4f174d2bf7bb532c471fec402fa862 /Bugzilla/Install | |
parent | 40e63525a8bda9132a4d2c0d296b2b7e89fe75de (diff) | |
download | bugzilla-d4e9172ad5f59d882ff372aff2cadd2c8c7f1ed3.tar.gz bugzilla-d4e9172ad5f59d882ff372aff2cadd2c8c7f1ed3.tar.xz |
Bug 377564: Indexes are not renamed when renaming tables
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat
Diffstat (limited to 'Bugzilla/Install')
-rw-r--r-- | Bugzilla/Install/DB.pm | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index f05f1722e..24a885118 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -504,6 +504,7 @@ sub update_table_definitions { {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1}); _fix_uppercase_custom_field_names(); + _fix_uppercase_index_names(); ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # @@ -2750,7 +2751,28 @@ sub _fix_uppercase_custom_field_names { undef, lc($name), $name); } } - +} + +sub _fix_uppercase_index_names { + # We forgot to fix indexes in the above code. + my $dbh = Bugzilla->dbh; + my $fields = $dbh->selectcol_arrayref( + 'SELECT name FROM fielddefs WHERE type = ? AND custom = 1', + undef, FIELD_TYPE_SINGLE_SELECT); + foreach my $field (@$fields) { + my $indexes = $dbh->bz_table_indexes($field); + foreach my $name (keys %$indexes) { + next if $name eq lc($name); + my $index = $indexes->{$name}; + # Lowercase the name and everything in the definition. + my $new_name = lc($name); + my @new_fields = map {lc($_)} @{$index->{FIELDS}}; + my $new_def = {FIELDS => \@new_fields, TYPE => $index->{TYPE}}; + $new_def = \@new_fields if !$index->{TYPE}; + $dbh->bz_drop_index($field, $name); + $dbh->bz_add_index($field, $new_name, $new_def); + } + } } 1; |