Skip to content

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

Update annotations.

Guo Xiang Tan214dac05defc
diff --git a/app/models/category.rb b/app/models/category.rb
index 426d901bfb2..49f8f4526d3 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -597,5 +597,5 @@ end
#
# index_categories_on_email_in (email_in) UNIQUE
# index_categories_on_topic_count (topic_count)
-# unique_index_categories_on_name (COALESCE(parent_category_id, '-1'::integer), name) UNIQUE
+# unique_index_categories_on_name ((COALESCE(parent_category_id, '-1'::integer)), name) UNIQUE
#
diff --git a/app/models/category_search_data.rb b/app/models/category_search_data.rb
index b23bf93604b..bb2286ac0ca 100644
--- a/app/models/category_search_data.rb
+++ b/app/models/category_search_data.rb
@@ -14,5 +14,5 @@ end
#
# Indexes
#
-# idx_search_category (search_data)
+# idx_search_category (search_data) USING gin
#
diff --git a/app/models/category_tag_stat.rb b/app/models/category_tag_stat.rb
index b5673bcdf50..2dc686c31f2 100644
--- a/app/models/category_tag_stat.rb
+++ b/app/models/category_tag_stat.rb
@@ -66,9 +66,9 @@ end
#
# Table name: category_tag_stats
#
-# id :integer not null, primary key
-# category_id :integer not null
-# tag_id :integer not null
+# id :bigint(8) not null, primary key
+# category_id :bigint(8) not null
+# tag_id :bigint(8) not null
# topic_count :integer default(0), not null
#
# Indexes
diff --git a/app/models/email_log.rb b/app/models/email_log.rb
index 0fafa1bcc04..d365ae01f47 100644
--- a/app/models/email_log.rb
+++ b/app/models/email_log.rb
@@ -90,12 +90,12 @@ end
#
# Indexes
#
-# idx_email_logs_user_created_filtered (user_id,created_at)
+# idx_email_logs_user_created_filtered (user_id,created_at) WHERE (skipped = false)
# index_email_logs_on_created_at (created_at)
# index_email_logs_on_message_id (message_id)
# index_email_logs_on_post_id (post_id)
# index_email_logs_on_reply_key (reply_key)
# index_email_logs_on_skipped_and_created_at (skipped,created_at)
# index_email_logs_on_topic_id (topic_id)
-# index_email_logs_on_user_id_and_created_at (user_id,created_at)
+# index_email_logs_on_user_id_and_created_at (user_id,created_at DESC)
#
diff --git a/app/models/facebook_user_info.rb b/app/models/facebook_user_info.rb
index eb996113106..fd1ee517518 100644
--- a/app/models/facebook_user_info.rb
+++ b/app/models/facebook_user_info.rb
@@ -8,7 +8,7 @@ end
#
# id :integer not null, primary key
# user_id :integer not null
-# facebook_user_id :integer not null
+# facebook_user_id :bigint(8) not null
# username :string
# first_name :string
# last_name :string
diff --git a/app/models/notification.rb b/app/models/notification.rb
index 7a294d81bf3..27ecc9a4c30 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -227,9 +227,9 @@ end
#
# Indexes
#
-# idx_notifications_speedup_unread_count (user_id,notification_type)
+# idx_notifications_speedup_unread_count (user_id,notification_type) WHERE (NOT read)
# index_notifications_on_post_action_id (post_action_id)
# index_notifications_on_user_id_and_created_at (user_id,created_at)
-# index_notifications_on_user_id_and_id (user_id,id) UNIQUE
+# index_notifications_on_user_id_and_id (user_id,id) UNIQUE WHERE ((notification_type = 6) AND (NOT read))
# index_notifications_on_user_id_and_topic_id_and_post_number (user_id,topic_id,post_number)
#
diff --git a/app/models/post.rb b/app/models/post.rb
index 1e3777920f0..30def11cf6b 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -873,10 +873,12 @@ end
#
# Indexes
#
-# idx_posts_created_at_topic_id (created_at,topic_id)
-# idx_posts_deleted_posts (topic_id,post_number)
-# idx_posts_user_id_deleted_at (user_id)
-# index_posts_on_reply_to_post_number (reply_to_post_number)
-# index_posts_on_topic_id_and_post_number (topic_id,post_number) UNIQUE
-# index_posts_on_user_id_and_created_at (user_id,created_at)
+# idx_posts_created_at_topic_id (created_at,topic_id) WHERE (deleted_at IS NULL)
+# idx_posts_deleted_posts (topic_id,post_number) WHERE (deleted_at IS NOT NULL)
+# idx_posts_user_id_deleted_at (user_id) WHERE (deleted_at IS NULL)
+# index_posts_on_reply_to_post_number (reply_to_post_number)
+# index_posts_on_topic_id_and_percent_rank (topic_id,percent_rank)
+# index_posts_on_topic_id_and_post_number (topic_id,post_number) UNIQUE
+# index_posts_on_topic_id_and_sort_order (topic_id,sort_order)
+# index_posts_on_user_id_and_created_at (user_id,created_at)
#
diff --git a/app/models/post_action.rb b/app/models/post_action.rb
index 5af5e8cdf55..ecf453f756f 100644
--- a/app/models/post_action.rb
+++ b/app/models/post_action.rb
@@ -657,8 +657,8 @@ end
#
# Indexes
#
-# idx_unique_actions (user_id,post_action_type_id,post_id,targets_topic) UNIQUE
-# idx_unique_flags (user_id,post_id,targets_topic) UNIQUE
+# idx_unique_actions (user_id,post_action_type_id,post_id,targets_topic) UNIQUE WHERE ((deleted_at IS NULL) AND (disagreed_at IS NULL) AND (deferred_at IS NULL))
+# idx_unique_flags (user_id,post_id,targets_topic) UNIQUE WHERE ((deleted_at IS NULL) AND (disagreed_at IS NULL) AND (deferred_at IS NULL) AND (post_action_type_id = ANY (ARRAY[3, 4, 7, 8])))
# index_post_actions_on_post_id (post_id)
-# index_post_actions_on_user_id_and_post_action_type_id (user_id,post_action_type_id)
+# index_post_actions_on_user_id_and_post_action_type_id (user_id,post_action_type_id) WHERE (deleted_at IS NULL)
#
diff --git a/app/models/post_custom_field.rb b/app/models/post_custom_field.rb
index 1eedcc88486..8c32eb80302 100644
--- a/app/models/post_custom_field.rb
+++ b/app/models/post_custom_field.rb
@@ -15,7 +15,7 @@ end
#
# Indexes
#
-# idx_post_custom_fields_akismet (post_id)
+# idx_post_custom_fields_akismet (post_id) WHERE (((name)::text = 'AKISMET_STATE'::text) AND (value = 'needs_review'::text))
# index_post_custom_fields_on_name_and_value (name, "left"(value, 200))
# index_post_custom_fields_on_post_id_and_name (post_id,name)
#
diff --git a/app/models/post_search_data.rb b/app/models/post_search_data.rb
index 58940e693b9..c30aa7a871e 100644
--- a/app/models/post_search_data.rb
+++ b/app/models/post_search_data.rb
@@ -14,5 +14,5 @@ end
#
# Indexes
#
-# idx_search_post (search_data)
+# idx_search_post (search_data) USING gin
#
diff --git a/app/models/push_subscription.rb b/app/models/push_subscription.rb
index 00dc2176bb4..caa68558d11 100644
--- a/app/models/push_subscription.rb
+++ b/app/models/push_subscription.rb
@@ -6,7 +6,7 @@ end
#
# Table name: push_subscriptions
#
-# id :integer not null, primary key
+# id :bigint(8) not null, primary key
# user_id :integer not null
# data :string not null
# created_at :datetime not null
diff --git a/app/models/shared_draft.rb b/app/models/shared_draft.rb
index a8a1b93b89e..c45b30ea8eb 100644
--- a/app/models/shared_draft.rb
+++ b/app/models/shared_draft.rb
@@ -11,7 +11,7 @@ end
# category_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
-# id :integer not null, primary key
+# id :bigint(8) not null, primary key
#
# Indexes
#
diff --git a/app/models/tag_group_permission.rb b/app/models/tag_group_permission.rb
index f2a27c1c872..49f4a97333f 100644
--- a/app/models/tag_group_permission.rb
+++ b/app/models/tag_group_permission.rb
@@ -12,9 +12,9 @@ end
#
# Table name: tag_group_permissions
#
-# id :integer not null, primary key
-# tag_group_id :integer not null
-# group_id :integer not null
+# id :bigint(8) not null, primary key
+# tag_group_id :bigint(8) not null
+# group_id :bigint(8) not null
# permission_type :integer default(1), not null
# created_at :datetime not null
# updated_at :datetime not null
diff --git a/app/models/tag_search_data.rb b/app/models/tag_search_data.rb
index d853da634b1..01d8678fbcb 100644
--- a/app/models/tag_search_data.rb
+++ b/app/models/tag_search_data.rb
@@ -14,5 +14,5 @@ end
#
# Indexes
#
-# idx_search_tag (search_data)
+# idx_search_tag (search_data) USING gin
#
diff --git a/app/models/theme_setting.rb b/app/models/theme_setting.rb
index 782d2148649..4134d4cb10e 100644
--- a/app/models/theme_setting.rb
+++ b/app/models/theme_setting.rb
@@ -56,7 +56,7 @@ end
#
# Table name: theme_settings
#
-# id :integer not null, primary key
+# id :bigint(8) not null, primary key
# name :string(255) not null
# data_type :integer not null
# value :text
diff --git a/app/models/topic.rb b/app/models/topic.rb
index cf7b59bd1cc..4b2256aa7dd 100644
--- a/app/models/topic.rb
+++ b/app/models/topic.rb
@@ -1453,12 +1453,12 @@ end
# Indexes
#
# idx_topics_front_page (deleted_at,visible,archetype,category_id,id)
-# idx_topics_user_id_deleted_at (user_id)
-# idxtopicslug (slug)
+# 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_topics_on_created_at_and_visible (created_at,visible)
+# 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_lower_title (lower((title)::text))
-# index_topics_on_pinned_at (pinned_at)
-# index_topics_on_pinned_globally (pinned_globally)
+# index_topics_on_pinned_at (pinned_at) WHERE (pinned_at IS NOT NULL)
+# index_topics_on_pinned_globally (pinned_globally) WHERE pinned_globally
#
diff --git a/app/models/topic_custom_field.rb b/app/models/topic_custom_field.rb
index 5dd6e53c731..e539bb90f63 100644
--- a/app/models/topic_custom_field.rb
+++ b/app/models/topic_custom_field.rb
@@ -16,5 +16,5 @@ end
# Indexes
#
# index_topic_custom_fields_on_topic_id_and_name (topic_id,name)
-# topic_custom_fields_value_key_idx (value,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_search_data.rb b/app/models/topic_search_data.rb
index ddf065327be..7203a84709b 100644
--- a/app/models/topic_search_data.rb
+++ b/app/models/topic_search_data.rb
@@ -14,5 +14,5 @@ end
#
# Indexes
#
-# idx_search_topic (search_data)
+# idx_search_topic (search_data) USING gin
#
diff --git a/app/models/topic_timer.rb b/app/models/topic_timer.rb
index e481ec1b26e..e884f33aded 100644
--- a/app/models/topic_timer.rb
+++ b/app/models/topic_timer.rb
@@ -164,6 +164,6 @@ end
#
# Indexes
#
-# idx_topic_id_public_type_deleted_at (topic_id) UNIQUE
+# idx_topic_id_public_type_deleted_at (topic_id) UNIQUE WHERE ((public_type = true) AND (deleted_at IS NULL))
# index_topic_timers_on_user_id (user_id)
#
diff --git a/app/models/twitter_user_info.rb b/app/models/twitter_user_info.rb
index a57608a4684..07302bc7771 100644
--- a/app/models/twitter_user_info.rb
+++ b/app/models/twitter_user_info.rb
@@ -9,7 +9,7 @@ end
# id :integer not null, primary key
# user_id :integer not null
# screen_name :string not null
-# twitter_user_id :integer not null
+# twitter_user_id :bigint(8) not null
# created_at :datetime not null
# updated_at :datetime not null
# email :string(1000)
diff --git a/app/models/user.rb b/app/models/user.rb
index bf4b0bd3e01..8cfa1bad3ad 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1314,8 +1314,8 @@ end
#
# Indexes
#
-# idx_users_admin (id)
-# idx_users_moderator (id)
+# idx_users_admin (id) WHERE admin
+# idx_users_moderator (id) WHERE moderator
# index_users_on_last_posted_at (last_posted_at)
# index_users_on_last_seen_at (last_seen_at)
# index_users_on_uploaded_avatar_id (uploaded_avatar_id)
diff --git a/app/models/user_badge.rb b/app/models/user_badge.rb
index b0b4ce354c5..1e462878926 100644
--- a/app/models/user_badge.rb
+++ b/app/models/user_badge.rb
@@ -47,7 +47,7 @@ end
# Indexes
#
# index_user_badges_on_badge_id_and_user_id (badge_id,user_id)
-# index_user_badges_on_badge_id_and_user_id_and_post_id (badge_id,user_id,post_id) UNIQUE
-# index_user_badges_on_badge_id_and_user_id_and_seq (badge_id,user_id,seq) UNIQUE
+# index_user_badges_on_badge_id_and_user_id_and_post_id (badge_id,user_id,post_id) UNIQUE WHERE (post_id IS NOT NULL)
+# index_user_badges_on_badge_id_and_user_id_and_seq (badge_id,user_id,seq) UNIQUE WHERE (post_id IS NULL)
# index_user_badges_on_user_id (user_id)
#
diff --git a/app/models/user_email.rb b/app/models/user_email.rb
index aaf608a6247..fca7a28967f 100644
--- a/app/models/user_email.rb
+++ b/app/models/user_email.rb
@@ -61,5 +61,5 @@ end
#
# index_user_emails_on_email (lower((email)::text)) UNIQUE
# index_user_emails_on_user_id (user_id)
-# index_user_emails_on_user_id_and_primary (user_id,primary) UNIQUE
+# index_user_emails_on_user_id_and_primary (user_id,primary) UNIQUE WHERE "primary"
#
diff --git a/app/models/user_search_data.rb b/app/models/user_search_data.rb
index 2de3be31cb0..ce61e991fa9 100644
--- a/app/models/user_search_data.rb
+++ b/app/models/user_search_data.rb
@@ -14,5 +14,5 @@ end
#
# Indexes
#
-# idx_search_user (search_data)
+# idx_search_user (search_data) USING gin
#
diff --git a/app/models/user_second_factor.rb b/app/models/user_second_factor.rb
index 2cb71049899..fcf17e14dce 100644
--- a/app/models/user_second_factor.rb
+++ b/app/models/user_second_factor.rb
@@ -22,7 +22,7 @@ end
#
# Table name: user_second_factors
#
-# id :integer not null, primary key
+# id :bigint(8) not null, primary key
# user_id :integer not null
# method :integer not null
# data :string not null
diff --git a/app/models/web_crawler_request.rb b/app/models/web_crawler_request.rb
index 8f082222d82..905cb835ae3 100644
--- a/app/models/web_crawler_request.rb
+++ b/app/models/web_crawler_request.rb
@@ -79,7 +79,7 @@ end
#
# Table name: web_crawler_requests
#
-# id :integer not null, primary key
+# id :bigint(8) not null, primary key
# date :date not null
# user_agent :string not null
# count :integer default(0), not null