Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add missing indexes to user_profiles (#8691)

Jarek Radosz531016f99b16
diff --git a/app/models/user_custom_field.rb b/app/models/user_custom_field.rb
index 0fb77e5f634..bba98cd9b49 100644
--- a/app/models/user_custom_field.rb
+++ b/app/models/user_custom_field.rb
@@ -17,5 +17,7 @@ end
#
# Indexes
#
-# index_user_custom_fields_on_user_id_and_name (user_id,name)
+# idx_user_custom_fields_last_reminded_at (name,user_id) UNIQUE WHERE ((name)::text = 'last_reminded_at'::text)
+# idx_user_custom_fields_remind_assigns_frequency (name,user_id) UNIQUE WHERE ((name)::text = 'remind_assigns_frequency'::text)
+# index_user_custom_fields_on_user_id_and_name (user_id,name)
#
diff --git a/app/models/user_profile.rb b/app/models/user_profile.rb
index a60ba7d83ac..ad2701e70d4 100644
--- a/app/models/user_profile.rb
+++ b/app/models/user_profile.rb
@@ -171,10 +171,10 @@ end
#
# Indexes
#
-# index_user_profiles_on_bio_cooked_version (bio_cooked_version)
-# index_user_profiles_on_card_background (card_background)
-# index_user_profiles_on_granted_title_badge_id (granted_title_badge_id)
-# index_user_profiles_on_profile_background (profile_background)
+# index_user_profiles_on_bio_cooked_version (bio_cooked_version)
+# index_user_profiles_on_card_background_upload_id (card_background_upload_id)
+# index_user_profiles_on_granted_title_badge_id (granted_title_badge_id)
+# index_user_profiles_on_profile_background_upload_id (profile_background_upload_id)
#
# Foreign Keys
#
diff --git a/app/models/user_stat.rb b/app/models/user_stat.rb
index ffd7057593a..cda2c1513ab 100644
--- a/app/models/user_stat.rb
+++ b/app/models/user_stat.rb
@@ -224,4 +224,5 @@ end
# flags_disagreed :integer default(0), not null
# flags_ignored :integer default(0), not null
# first_unread_at :datetime not null
+# distinct_badge_count :integer default(0), not null
#
diff --git a/db/migrate/20200109130028_update_user_profiles_indexes.rb b/db/migrate/20200109130028_update_user_profiles_indexes.rb
new file mode 100644
index 00000000000..861a78a9889
--- /dev/null
+++ b/db/migrate/20200109130028_update_user_profiles_indexes.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class UpdateUserProfilesIndexes < ActiveRecord::Migration[6.0]
+ def change
+ remove_index :user_profiles, :card_background
+ add_index :user_profiles, :card_background_upload_id
+
+ remove_index :user_profiles, :profile_background
+ add_index :user_profiles, :profile_background_upload_id
+ end
+end