From 0d240c01b73984b61922c12d192a52b41eaf8e55 Mon Sep 17 00:00:00 2001 From: Luke Baker Date: Thu, 20 Jan 2011 15:52:22 -0500 Subject: [PATCH] update an index on appearances by add / del --- db/migrate/20110120202304_add_voter_id_index_on_appearances.rb | 9 +++++++++ db/migrate/20110120204933_remove_question_id_index_on_appearances.rb | 9 +++++++++ db/schema.rb | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20110120202304_add_voter_id_index_on_appearances.rb create mode 100644 db/migrate/20110120204933_remove_question_id_index_on_appearances.rb diff --git a/db/migrate/20110120202304_add_voter_id_index_on_appearances.rb b/db/migrate/20110120202304_add_voter_id_index_on_appearances.rb new file mode 100644 index 0000000..9a000c3 --- /dev/null +++ b/db/migrate/20110120202304_add_voter_id_index_on_appearances.rb @@ -0,0 +1,9 @@ +class AddVoterIdIndexOnAppearances < ActiveRecord::Migration + def self.up + add_index :appearances, [:question_id, :voter_id], :name => 'index_appearances_on_question_id_voter_id' + end + + def self.down + remove_index :appearances, :name => :index_appearances_on_question_id_voter_id + end +end diff --git a/db/migrate/20110120204933_remove_question_id_index_on_appearances.rb b/db/migrate/20110120204933_remove_question_id_index_on_appearances.rb new file mode 100644 index 0000000..beff328 --- /dev/null +++ b/db/migrate/20110120204933_remove_question_id_index_on_appearances.rb @@ -0,0 +1,9 @@ +class RemoveQuestionIdIndexOnAppearances < ActiveRecord::Migration + def self.up + remove_index :appearances, :question_id + end + + def self.down + add_index :appearances, :question_id + end +end diff --git a/db/schema.rb b/db/schema.rb index b093bee..b899aea 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110119165820) do +ActiveRecord::Schema.define(:version => 20110120204933) do create_table "appearances", :force => true do |t| t.integer "voter_id" @@ -26,7 +26,7 @@ ActiveRecord::Schema.define(:version => 20110119165820) do end add_index "appearances", ["lookup"], :name => "index_appearances_on_lookup" - add_index "appearances", ["question_id"], :name => "index_appearances_on_question_id" + add_index "appearances", ["question_id", "voter_id"], :name => "index_appearances_on_question_id_voter_id" create_table "choices", :force => true do |t| t.integer "item_id" -- libgit2 0.21.2