From d8104d2500062ee21f15e64d6b6836c95bdec76a Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 30 Nov 2013 15:01:07 -0500 Subject: [PATCH] #1140: Add multi-column creator/post indexes --- ...and_post_id_indexes_to_comments_and_notes.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 db/migrate/20131130190411_add_creator_id_and_post_id_indexes_to_comments_and_notes.rb diff --git a/db/migrate/20131130190411_add_creator_id_and_post_id_indexes_to_comments_and_notes.rb b/db/migrate/20131130190411_add_creator_id_and_post_id_indexes_to_comments_and_notes.rb new file mode 100644 index 000000000..990cd9b4b --- /dev/null +++ b/db/migrate/20131130190411_add_creator_id_and_post_id_indexes_to_comments_and_notes.rb @@ -0,0 +1,17 @@ +class AddCreatorIdAndPostIdIndexesToCommentsAndNotes < ActiveRecord::Migration + def self.up + execute "set statement_timeout = 0" + remove_index :comments, :creator_id + remove_index :notes, :creator_id + add_index :comments, [:creator_id, :post_id] + add_index :notes, [:creator_id, :post_id] + end + + def self.down + execute "set statement_timeout = 0" + remove_index :comments, [:creator_id, :post_id] + remove_index :notes, [:creator_id, :post_id] + add_index :comments, :creator_id + add_index :notes, :creator_id + end +end