A platform for community discussion. Free, open, simple.
FIX: Add index on user_api_keys.key_hash (#9387)
Dan Ungureanub64b590cfb42
diff --git a/app/models/user_api_key.rb b/app/models/user_api_key.rbindex e937c44a8e0..4fac1230bc9 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.rbnew file mode 100644index 00000000000..9d6c67f6511--- /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