From 09a569aabac7ed2f58d52aaa97f683194dd96814 Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Wed, 23 Oct 2019 12:27:56 +0300 Subject: [PATCH] PERF: Add unique index oauth2_user_infos(user_id, provider) (#8230) --- app/models/oauth2_user_info.rb | 3 ++- db/migrate/20191022155215_add_index_to_oauth2_user_info.rb | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20191022155215_add_index_to_oauth2_user_info.rb diff --git a/app/models/oauth2_user_info.rb b/app/models/oauth2_user_info.rb index ed9f217caa1..69f35ed731c 100644 --- a/app/models/oauth2_user_info.rb +++ b/app/models/oauth2_user_info.rb @@ -20,5 +20,6 @@ end # # Indexes # -# index_oauth2_user_infos_on_uid_and_provider (uid,provider) UNIQUE +# index_oauth2_user_infos_on_uid_and_provider (uid,provider) UNIQUE +# index_oauth2_user_infos_on_user_id_and_provider (user_id,provider) UNIQUE # diff --git a/db/migrate/20191022155215_add_index_to_oauth2_user_info.rb b/db/migrate/20191022155215_add_index_to_oauth2_user_info.rb new file mode 100644 index 00000000000..dc9093a6c06 --- /dev/null +++ b/db/migrate/20191022155215_add_index_to_oauth2_user_info.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddIndexToOauth2UserInfo < ActiveRecord::Migration[6.0] + def change + add_index :oauth2_user_infos, [:user_id, :provider], unique: true + end +end