]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 516712: Make it possible to upgrade when you have empty strings in the profiles...
authormkanat%bugzilla.org <>
Tue, 22 Sep 2009 00:01:06 +0000 (00:01 +0000)
committermkanat%bugzilla.org <>
Tue, 22 Sep 2009 00:01:06 +0000 (00:01 +0000)
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=dkl, a=mkanat

Bugzilla/Install/DB.pm

index ec6c8ce9c7dba9a98b1c7115944bcd97a8647e92..8636a58c920256f743aadfabc2ab7f1a8534823a 100644 (file)
@@ -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__