From 53bd3f4b34334a04cf66f0b38b243ae3402f17ac Mon Sep 17 00:00:00 2001
From: ArtOfCode- <hello@artofcode.co.uk>
Date: Wed, 1 Jul 2020 14:27:29 +0100
Subject: [PATCH] Index vote counts

---
 db/migrate/20200701132654_add_indexes_to_vote_counts.rb | 6 ++++++
 db/schema.rb                                            | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)
 create mode 100644 db/migrate/20200701132654_add_indexes_to_vote_counts.rb

diff --git a/db/migrate/20200701132654_add_indexes_to_vote_counts.rb b/db/migrate/20200701132654_add_indexes_to_vote_counts.rb
new file mode 100644
index 000000000..af2dd081a
--- /dev/null
+++ b/db/migrate/20200701132654_add_indexes_to_vote_counts.rb
@@ -0,0 +1,6 @@
+class AddIndexesToVoteCounts < ActiveRecord::Migration[5.2]
+  def change
+    add_index :posts, :upvote_count
+    add_index :posts, :downvote_count
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index d00a71643..394729567 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2020_07_01_132522) do
+ActiveRecord::Schema.define(version: 2020_07_01_132654) do
 
   create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", force: :cascade do |t|
     t.string "name", null: false
@@ -246,6 +246,7 @@ ActiveRecord::Schema.define(version: 2020_07_01_132522) do
     t.index ["close_reason_id"], name: "index_posts_on_close_reason_id"
     t.index ["community_id"], name: "index_posts_on_community_id"
     t.index ["deleted"], name: "index_posts_on_deleted"
+    t.index ["downvote_count"], name: "index_posts_on_downvote_count"
     t.index ["duplicate_post_id"], name: "index_posts_on_duplicate_post_id"
     t.index ["last_activity"], name: "index_posts_on_last_activity"
     t.index ["last_activity_by_id"], name: "index_posts_on_last_activity_by_id"
@@ -254,6 +255,7 @@ ActiveRecord::Schema.define(version: 2020_07_01_132522) do
     t.index ["post_type_id"], name: "index_posts_on_post_type_id"
     t.index ["score"], name: "index_posts_on_score"
     t.index ["tags_cache"], name: "index_posts_on_tags_cache"
+    t.index ["upvote_count"], name: "index_posts_on_upvote_count"
     t.index ["user_id"], name: "index_posts_on_user_id"
   end
 
-- 
GitLab