]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1044561: Bad definition of indexes for the new user_api_keys DB table
authorFrédéric Buclin <LpSolit@gmail.com>
Thu, 31 Jul 2014 16:38:18 +0000 (18:38 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Thu, 31 Jul 2014 16:38:18 +0000 (18:38 +0200)
r=sgreen a=glob

Bugzilla/DB/Schema.pm
Bugzilla/Install/DB.pm

index b175f15549dfa1880d23855a16b1d35acba15162..2fa811042ea8829349e295eddcc19ae0ffa95c4f 100644 (file)
@@ -1749,8 +1749,8 @@ use constant ABSTRACT_SCHEMA => {
             last_used     => {TYPE => 'DATETIME'},
         ],
         INDEXES => [
-            user_api_keys_key     => {FIELDS => ['api_key'], TYPE => 'UNIQUE'},
-            user_api_keys_user_id => {FIELDS => ['user_id']},
+            user_api_keys_api_key_idx => {FIELDS => ['api_key'], TYPE => 'UNIQUE'},
+            user_api_keys_user_id_idx => ['user_id'],
         ],
     },
 };
index bbddf162008eec63be9ea8ec0ba059a316d00e1c..74b2b1e39b162fb40d3664e59e83f40d59f00924 100644 (file)
@@ -723,6 +723,9 @@ sub update_table_definitions {
     $dbh->bz_alter_column('tokens', 'tokentype',
                           {TYPE => 'varchar(16)', NOTNULL => 1});
 
+    # 2014-07-27 LpSolit@gmail.com - Bug 1044561
+    _fix_user_api_keys_indexes();
+
     ################################################################
     # New --TABLE-- changes should go *** A B O V E *** this point #
     ################################################################
@@ -3881,6 +3884,20 @@ sub _fix_components_primary_key {
     }
 }
 
+sub _fix_user_api_keys_indexes {
+    my $dbh = Bugzilla->dbh;
+
+    if ($dbh->bz_index_info('user_api_keys', 'user_api_keys_key')) {
+        $dbh->bz_drop_index('user_api_keys', 'user_api_keys_key');
+        $dbh->bz_add_index('user_api_keys', 'user_api_keys_api_key_idx',
+                           { FIELDS => ['api_key'], TYPE => 'UNIQUE' });
+    }
+    if ($dbh->bz_index_info('user_api_keys', 'user_api_keys_user_id')) {
+        $dbh->bz_drop_index('user_api_keys', 'user_api_keys_user_id');
+        $dbh->bz_add_index('user_api_keys', 'user_api_keys_user_id_idx', ['user_id']);
+    }
+}
+
 1;
 
 __END__