From: mkanat%bugzilla.org <> Date: Tue, 22 Sep 2009 00:01:06 +0000 (+0000) Subject: Bug 516712: Make it possible to upgrade when you have empty strings in the profiles... X-Git-Tag: bugzilla-3.4.3~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3932d2e8793feecd5acda3cbd99479de6ad8f104;p=thirdparty%2Fbugzilla.git Bug 516712: Make it possible to upgrade when you have empty strings in the profiles.extern_id column Patch by Max Kanat-Alexander r=dkl, a=mkanat --- diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index ec6c8ce9c7..8636a58c92 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -555,8 +555,7 @@ sub update_table_definitions { _add_visiblity_value_to_value_tables(); # 2009-03-02 arbingersys@gmail.com - Bug 423613 - $dbh->bz_add_index('profiles', 'profiles_extern_id_idx', - {TYPE => 'UNIQUE', FIELDS => [qw(extern_id)]}); + _add_extern_id_index(); ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # @@ -3144,6 +3143,17 @@ sub _add_visiblity_value_to_value_tables { } } +sub _add_extern_id_index { + my $dbh = Bugzilla->dbh; + if (!$dbh->bz_index_info('profiles', 'profiles_extern_id_idx')) { + # Some Bugzillas have a multiple empty strings in extern_id, + # which need to be converted to NULLs before we add the index. + $dbh->do("UPDATE profiles SET extern_id = NULL WHERE extern_id = ''"); + $dbh->bz_add_index('profiles', 'profiles_extern_id_idx', + {TYPE => 'UNIQUE', FIELDS => [qw(extern_id)]}); + } +} + 1; __END__