From 2578ac15b6d9eae8c2d93fe973e202c378eb4bc2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 19 Jan 2011 14:29:22 -0800 Subject: [PATCH] Add some indicies --- db/migrate/20110119221746_add_indicies.rb | 29 +++++++++++++++++++++++ db/schema.rb | 23 +++++++----------- 2 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 db/migrate/20110119221746_add_indicies.rb diff --git a/db/migrate/20110119221746_add_indicies.rb b/db/migrate/20110119221746_add_indicies.rb new file mode 100644 index 000000000..13fe89a22 --- /dev/null +++ b/db/migrate/20110119221746_add_indicies.rb @@ -0,0 +1,29 @@ +class AddIndicies < ActiveRecord::Migration + def self.up + add_index :comments, :person_id + + add_index :invitations, :recipient_id + add_index :invitations, :aspect_id + + add_index :notifications, :target_id + add_index :notifications, :recipient_id + + add_index :posts, :status_message_id + add_index :posts, [:status_message_id, :pending] + add_index :posts, [:type, :pending, :id] + end + + def self.down + remove_index :comments, :person_id + + remove_index :invitations, :recipient_id + remove_index :invitations, :aspect_id + + remove_index :notifications, :target_id + remove_index :notifications, :recipient_id + + remove_index :posts, :status_message_id + remove_index :posts, [:status_message_id, :pending] + remove_index :posts, [:type, :pending, :id] + end +end diff --git a/db/schema.rb b/db/schema.rb index 83c673a0f..d356b341e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110119060243) do +ActiveRecord::Schema.define(:version => 20110119221746) do create_table "aspect_memberships", :force => true do |t| t.integer "aspect_id" @@ -50,6 +50,7 @@ ActiveRecord::Schema.define(:version => 20110119060243) do add_index "comments", ["guid"], :name => "index_comments_on_guid", :unique => true add_index "comments", ["mongo_id"], :name => "index_comments_on_mongo_id" + add_index "comments", ["person_id"], :name => "index_comments_on_person_id" add_index "comments", ["post_id"], :name => "index_comments_on_post_id" create_table "contacts", :force => true do |t| @@ -66,19 +67,6 @@ ActiveRecord::Schema.define(:version => 20110119060243) do add_index "contacts", ["user_id", "pending"], :name => "index_contacts_on_user_id_and_pending" add_index "contacts", ["user_id", "person_id"], :name => "index_contacts_on_user_id_and_person_id", :unique => true - create_table "histories", :force => true do |t| - t.string "message" - t.string "username" - t.integer "item" - t.string "table" - t.integer "month", :limit => 2 - t.integer "year", :limit => 8 - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "histories", ["item", "table", "month", "year"], :name => "index_histories_on_item_and_table_and_month_and_year" - create_table "invitations", :force => true do |t| t.text "message" t.integer "sender_id" @@ -89,7 +77,9 @@ ActiveRecord::Schema.define(:version => 20110119060243) do t.string "mongo_id" end + add_index "invitations", ["aspect_id"], :name => "index_invitations_on_aspect_id" add_index "invitations", ["mongo_id"], :name => "index_invitations_on_mongo_id" + add_index "invitations", ["recipient_id"], :name => "index_invitations_on_recipient_id" add_index "invitations", ["sender_id"], :name => "index_invitations_on_sender_id" create_table "mongo_aspect_memberships", :force => true do |t| @@ -304,6 +294,8 @@ ActiveRecord::Schema.define(:version => 20110119060243) do end add_index "notifications", ["mongo_id"], :name => "index_notifications_on_mongo_id" + add_index "notifications", ["recipient_id"], :name => "index_notifications_on_recipient_id" + add_index "notifications", ["target_id"], :name => "index_notifications_on_target_id" add_index "notifications", ["target_type", "target_id"], :name => "index_notifications_on_target_type_and_target_id" create_table "people", :force => true do |t| @@ -356,6 +348,9 @@ ActiveRecord::Schema.define(:version => 20110119060243) do add_index "posts", ["guid"], :name => "index_posts_on_guid" add_index "posts", ["mongo_id"], :name => "index_posts_on_mongo_id" add_index "posts", ["person_id"], :name => "index_posts_on_person_id" + add_index "posts", ["status_message_id", "pending"], :name => "index_posts_on_status_message_id_and_pending" + add_index "posts", ["status_message_id"], :name => "index_posts_on_status_message_id" + add_index "posts", ["type", "pending", "id"], :name => "index_posts_on_type_and_pending_and_id" add_index "posts", ["type"], :name => "index_posts_on_type" create_table "profiles", :force => true do |t|