FIX: Add index on user_api_keys.key_hash (#9387)

FIX: Add index on user_api_keys.key_hash (#9387)

diff --git a/app/models/user_api_key.rb b/app/models/user_api_key.rb
index e937c44..4fac123 100644
--- a/app/models/user_api_key.rb
+++ b/app/models/user_api_key.rb
@@ -116,5 +116,6 @@ end
 #
 #  index_user_api_keys_on_client_id  (client_id) UNIQUE
 #  index_user_api_keys_on_key        (key) UNIQUE
+#  index_user_api_keys_on_key_hash   (key_hash) UNIQUE
 #  index_user_api_keys_on_user_id    (user_id)
 #
diff --git a/db/migrate/20200408121834_add_index_to_user_api_key_on_key_hash.rb b/db/migrate/20200408121834_add_index_to_user_api_key_on_key_hash.rb
new file mode 100644
index 0000000..9d6c67f
--- /dev/null
+++ b/db/migrate/20200408121834_add_index_to_user_api_key_on_key_hash.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddIndexToUserApiKeyOnKeyHash < ActiveRecord::Migration[6.0]
+  def change
+    add_index :user_api_keys, :key_hash, unique: true
+  end
+end

GitHub sha: b64b590c

This commit appears in #9387 which was approved by eviltrout. It was merged by udan11.