From b64b590cfb42b2d8b8129d2bee44e6407f11d284 Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Wed, 8 Apr 2020 19:49:18 +0300 Subject: [PATCH] FIX: Add index on user_api_keys.key_hash (#9387) --- app/models/user_api_key.rb | 1 + ...20200408121834_add_index_to_user_api_key_on_key_hash.rb | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 db/migrate/20200408121834_add_index_to_user_api_key_on_key_hash.rb diff --git a/app/models/user_api_key.rb b/app/models/user_api_key.rb index 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.rb new file mode 100644 index 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