From c6bf70c87082eb17e37c7452ac862a53add0d9d6 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Tue, 27 Oct 2020 23:42:33 +0530 Subject: [PATCH] DEV: annotate models (#11047) --- app/models/category.rb | 2 +- app/models/group_user.rb | 1 + app/models/imap_sync_log.rb | 4 ++-- app/models/post_search_data.rb | 1 + app/models/screened_email.rb | 4 ++-- app/models/theme_modifier_set.rb | 13 +++++++------ app/models/topic.rb | 5 +++-- app/models/topic_custom_field.rb | 7 ++++--- app/models/topic_link.rb | 12 ++++++------ app/models/topic_link_click.rb | 2 +- app/models/topic_user.rb | 6 +++--- app/models/user_action.rb | 4 ++-- app/models/user_api_key.rb | 1 - app/models/user_custom_field.rb | 5 ++++- app/models/user_history.rb | 6 +++--- app/models/user_ip_address_history.rb | 15 +++++++++++++++ app/models/user_stat.rb | 1 + 17 files changed, 56 insertions(+), 33 deletions(-) diff --git a/app/models/category.rb b/app/models/category.rb index 48715f4d4e2..13202e4b521 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -998,9 +998,9 @@ end # Indexes # # index_categories_on_email_in (email_in) UNIQUE +# index_categories_on_forum_thread_count (topic_count) # index_categories_on_reviewable_by_group_id (reviewable_by_group_id) # index_categories_on_search_priority (search_priority) -# index_categories_on_topic_count (topic_count) # unique_index_categories_on_name (COALESCE(parent_category_id, '-1'::integer), name) UNIQUE # unique_index_categories_on_slug (COALESCE(parent_category_id, '-1'::integer), slug) UNIQUE WHERE ((slug)::text <> ''::text) # diff --git a/app/models/group_user.rb b/app/models/group_user.rb index 820bbcc1127..521709f3cd2 100644 --- a/app/models/group_user.rb +++ b/app/models/group_user.rb @@ -196,6 +196,7 @@ end # updated_at :datetime not null # owner :boolean default(FALSE), not null # notification_level :integer default(2), not null +# first_unread_pm_at :datetime not null # # Indexes # diff --git a/app/models/imap_sync_log.rb b/app/models/imap_sync_log.rb index 71b285c6b81..46284a18d85 100644 --- a/app/models/imap_sync_log.rb +++ b/app/models/imap_sync_log.rb @@ -42,8 +42,8 @@ end # Table name: imap_sync_logs # # id :bigint not null, primary key -# level :integer -# message :string +# level :integer not null +# message :string not null # group_id :bigint # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/post_search_data.rb b/app/models/post_search_data.rb index 3a12c0bcf39..a08b2d46ffb 100644 --- a/app/models/post_search_data.rb +++ b/app/models/post_search_data.rb @@ -17,6 +17,7 @@ end # # Indexes # +# idx_recent_regular_post_search_data (search_data) WHERE ((NOT private_message) AND (post_id >= 0)) USING gin # idx_search_post (search_data) USING gin # index_post_search_data_on_post_id_and_version_and_locale (post_id,version,locale) # diff --git a/app/models/screened_email.rb b/app/models/screened_email.rb index 3f8a604d9b1..9bbdeb81b61 100644 --- a/app/models/screened_email.rb +++ b/app/models/screened_email.rb @@ -90,6 +90,6 @@ end # # Indexes # -# index_screened_emails_on_email (email) UNIQUE -# index_screened_emails_on_last_match_at (last_match_at) +# index_blocked_emails_on_email (email) UNIQUE +# index_blocked_emails_on_last_match_at (last_match_at) # diff --git a/app/models/theme_modifier_set.rb b/app/models/theme_modifier_set.rb index 781ea42f51f..91b39800a22 100644 --- a/app/models/theme_modifier_set.rb +++ b/app/models/theme_modifier_set.rb @@ -98,12 +98,13 @@ end # # Table name: theme_modifier_sets # -# id :bigint not null, primary key -# theme_id :bigint not null -# serialize_topic_excerpts :boolean -# csp_extensions :string is an Array -# svg_icons :string is an Array -# topic_thumbnail_sizes :string is an Array +# id :bigint not null, primary key +# theme_id :bigint not null +# serialize_topic_excerpts :boolean +# csp_extensions :string is an Array +# svg_icons :string is an Array +# discourse_teams_sidebar_disabled :boolean +# topic_thumbnail_sizes :string is an Array # # Indexes # diff --git a/app/models/topic.rb b/app/models/topic.rb index 976c1996a24..cecd42df79b 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -1770,7 +1770,6 @@ end # archetype :string default("regular"), not null # featured_user4_id :integer # notify_moderators_count :integer default(0), not null -# slow_mode_seconds :integer default(0), not null # spam_count :integer default(0), not null # pinned_at :datetime # score :float @@ -1788,13 +1787,14 @@ end # featured_link :string # reviewable_score :float default(0.0), not null # image_upload_id :bigint +# slow_mode_seconds :integer default(0), not null # # Indexes # # idx_topics_front_page (deleted_at,visible,archetype,category_id,id) # idx_topics_user_id_deleted_at (user_id) WHERE (deleted_at IS NULL) # idxtopicslug (slug) WHERE ((deleted_at IS NULL) AND (slug IS NOT NULL)) -# index_topics_on_bumped_at (bumped_at) +# index_forum_threads_on_bumped_at (bumped_at) # index_topics_on_created_at_and_visible (created_at,visible) WHERE ((deleted_at IS NULL) AND ((archetype)::text <> 'private_message'::text)) # index_topics_on_id_and_deleted_at (id,deleted_at) # index_topics_on_id_filtered_banner (id) UNIQUE WHERE (((archetype)::text = 'banner'::text) AND (deleted_at IS NULL)) @@ -1802,5 +1802,6 @@ end # index_topics_on_lower_title (lower((title)::text)) # index_topics_on_pinned_at (pinned_at) WHERE (pinned_at IS NOT NULL) # index_topics_on_pinned_globally (pinned_globally) WHERE pinned_globally +# index_topics_on_timestamps_private (bumped_at,created_at,updated_at) WHERE ((deleted_at IS NULL) AND ((archetype)::text = 'private_message'::text)) # index_topics_on_updated_at_public (updated_at,visible,highest_staff_post_number,highest_post_number,category_id,created_at,id) WHERE (((archetype)::text <> 'private_message'::text) AND (deleted_at IS NULL)) # diff --git a/app/models/topic_custom_field.rb b/app/models/topic_custom_field.rb index 85e839c8293..be69188da8b 100644 --- a/app/models/topic_custom_field.rb +++ b/app/models/topic_custom_field.rb @@ -17,7 +17,8 @@ end # # Indexes # -# idx_topic_custom_fields_topic_post_event_starts_at (name,topic_id) UNIQUE WHERE ((name)::text = 'TopicEventStartsAt'::text) -# index_topic_custom_fields_on_topic_id_and_name (topic_id,name) -# topic_custom_fields_value_key_idx (value,name) WHERE ((value IS NOT NULL) AND (char_length(value) < 400)) +# idx_topic_custom_fields_accepted_answer (topic_id) UNIQUE WHERE ((name)::text = 'accepted_answer_post_id'::text) +# index_topic_custom_fields_on_topic_id (topic_id) UNIQUE WHERE ((name)::text = 'vote_count'::text) +# index_topic_custom_fields_on_topic_id_and_name (topic_id,name) +# topic_custom_fields_value_key_idx (value,name) WHERE ((value IS NOT NULL) AND (char_length(value) < 400)) # diff --git a/app/models/topic_link.rb b/app/models/topic_link.rb index 134bde3b697..96c9d7270d7 100644 --- a/app/models/topic_link.rb +++ b/app/models/topic_link.rb @@ -402,10 +402,10 @@ end # # Indexes # -# index_topic_links_on_extension (extension) -# index_topic_links_on_link_post_id_and_reflection (link_post_id,reflection) -# index_topic_links_on_post_id (post_id) -# index_topic_links_on_topic_id (topic_id) -# index_topic_links_on_user_id (user_id) -# unique_post_links (topic_id,post_id,url) UNIQUE +# index_forum_thread_links_on_forum_thread_id (topic_id) +# index_forum_thread_links_on_forum_thread_id_and_post_id_and_url (topic_id,post_id,url) UNIQUE +# index_topic_links_on_extension (extension) +# index_topic_links_on_link_post_id_and_reflection (link_post_id,reflection) +# index_topic_links_on_post_id (post_id) +# index_topic_links_on_user_id (user_id) # diff --git a/app/models/topic_link_click.rb b/app/models/topic_link_click.rb index 63166cfb802..32526189050 100644 --- a/app/models/topic_link_click.rb +++ b/app/models/topic_link_click.rb @@ -128,5 +128,5 @@ end # # Indexes # -# by_link (topic_link_id) +# index_forum_thread_link_clicks_on_forum_thread_link_id (topic_link_id) # diff --git a/app/models/topic_user.rb b/app/models/topic_user.rb index ddd5226298f..bbf6283d07f 100644 --- a/app/models/topic_user.rb +++ b/app/models/topic_user.rb @@ -495,7 +495,6 @@ end # posted :boolean default(FALSE), not null # last_read_post_number :integer # highest_seen_post_number :integer -# last_posted_at :datetime # last_visited_at :datetime # first_visited_at :datetime # notification_level :integer default(1), not null @@ -507,9 +506,10 @@ end # last_emailed_post_number :integer # liked :boolean default(FALSE) # bookmarked :boolean default(FALSE) +# last_posted_at :datetime # # Indexes # -# index_topic_users_on_topic_id_and_user_id (topic_id,user_id) UNIQUE -# index_topic_users_on_user_id_and_topic_id (user_id,topic_id) UNIQUE +# index_forum_thread_users_on_forum_thread_id_and_user_id (topic_id,user_id) UNIQUE +# index_topic_users_on_user_id_and_topic_id (user_id,topic_id) UNIQUE # diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 51db3cb474d..60b6002739d 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -464,9 +464,9 @@ end # # idx_unique_rows (action_type,user_id,target_topic_id,target_post_id,acting_user_id) UNIQUE # idx_user_actions_speed_up_user_all (user_id,created_at,action_type) -# index_user_actions_on_acting_user_id (acting_user_id) +# index_actions_on_acting_user_id (acting_user_id) +# index_actions_on_user_id_and_action_type (user_id,action_type) # index_user_actions_on_action_type_and_created_at (action_type,created_at) # index_user_actions_on_target_post_id (target_post_id) # index_user_actions_on_target_user_id (target_user_id) WHERE (target_user_id IS NOT NULL) -# index_user_actions_on_user_id_and_action_type (user_id,action_type) # diff --git a/app/models/user_api_key.rb b/app/models/user_api_key.rb index 45b87369f18..1c708846b1b 100644 --- a/app/models/user_api_key.rb +++ b/app/models/user_api_key.rb @@ -79,7 +79,6 @@ end # created_at :datetime not null # updated_at :datetime not null # revoked_at :datetime -# scopes :text default([]), not null, is an Array # last_used_at :datetime not null # key_hash :string not null # diff --git a/app/models/user_custom_field.rb b/app/models/user_custom_field.rb index 0fb77e5f634..c38e65467e0 100644 --- a/app/models/user_custom_field.rb +++ b/app/models/user_custom_field.rb @@ -17,5 +17,8 @@ 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) +# idx_user_custom_fields_user_notes_count (name,user_id) UNIQUE WHERE ((name)::text = 'user_notes_count'::text) +# index_user_custom_fields_on_user_id_and_name (user_id,name) # diff --git a/app/models/user_history.rb b/app/models/user_history.rb index d9b7848bdd0..78b87c04aba 100644 --- a/app/models/user_history.rb +++ b/app/models/user_history.rb @@ -304,10 +304,10 @@ end # # Indexes # +# index_staff_action_logs_on_action_and_id (action,id) +# index_staff_action_logs_on_subject_and_id (subject,id) +# index_staff_action_logs_on_target_user_id_and_id (target_user_id,id) # index_user_histories_on_acting_user_id_and_action_and_id (acting_user_id,action,id) -# index_user_histories_on_action_and_id (action,id) # index_user_histories_on_category_id (category_id) -# index_user_histories_on_subject_and_id (subject,id) -# index_user_histories_on_target_user_id_and_id (target_user_id,id) # index_user_histories_on_topic_id_and_target_user_id_and_action (topic_id,target_user_id,action) # diff --git a/app/models/user_ip_address_history.rb b/app/models/user_ip_address_history.rb index 0e195d26c08..3e6a0f974d5 100644 --- a/app/models/user_ip_address_history.rb +++ b/app/models/user_ip_address_history.rb @@ -6,3 +6,18 @@ class UserIpAddressHistory < ActiveRecord::Base validates :user_id, presence: true validates :ip_address, presence: true, uniqueness: { scope: :user_id } end + +# == Schema Information +# +# Table name: user_ip_address_histories +# +# id :bigint not null, primary key +# user_id :integer not null +# ip_address :inet not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_user_ip_address_histories_on_user_id_and_ip_address (user_id,ip_address) UNIQUE +# diff --git a/app/models/user_stat.rb b/app/models/user_stat.rb index 364b4a2618e..2921233b2a2 100644 --- a/app/models/user_stat.rb +++ b/app/models/user_stat.rb @@ -290,5 +290,6 @@ end # flags_ignored :integer default(0), not null # first_unread_at :datetime not null # distinct_badge_count :integer default(0), not null +# first_unread_pm_at :datetime not null # digest_attempted_at :datetime #