add proper index to comments

This commit is contained in:
danielgrippi 2011-10-17 18:19:02 -07:00
parent b46200224e
commit 38d685e06e
2 changed files with 22 additions and 1 deletions

View file

@ -0,0 +1,18 @@
class AddBackIndexes < ActiveRecord::Migration
def self.up
# reduce index size
change_column :comments, :commentable_type, :string, :default => "Post", :null => false, :length => 60
change_column :share_visibilities, :shareable_type, :string, :default => "Post", :null => false, :length => 60
add_index :photos, :status_message_guid
add_index :comments, [:commentable_id, :commentable_type]
end
def self.down
remove_index :comments, :column => [:commentable_id, :commentable_type]
remove_index :photos, :column => :status_message_guid
change_column :share_visibilities, :shareable_type
change_column :comments, :commentable_type
end
end

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20111012215141) do ActiveRecord::Schema.define(:version => 20111018010003) do
create_table "aspect_memberships", :force => true do |t| create_table "aspect_memberships", :force => true do |t|
t.integer "aspect_id", :null => false t.integer "aspect_id", :null => false
@ -62,6 +62,7 @@ ActiveRecord::Schema.define(:version => 20111012215141) do
end end
add_index "comments", ["author_id"], :name => "index_comments_on_person_id" add_index "comments", ["author_id"], :name => "index_comments_on_person_id"
add_index "comments", ["commentable_id", "commentable_type"], :name => "index_comments_on_commentable_id_and_commentable_type"
add_index "comments", ["guid"], :name => "index_comments_on_guid", :unique => true add_index "comments", ["guid"], :name => "index_comments_on_guid", :unique => true
create_table "contacts", :force => true do |t| create_table "contacts", :force => true do |t|
@ -262,6 +263,8 @@ ActiveRecord::Schema.define(:version => 20111012215141) do
t.integer "comments_count" t.integer "comments_count"
end end
add_index "photos", ["status_message_guid"], :name => "index_photos_on_status_message_guid"
create_table "pods", :force => true do |t| create_table "pods", :force => true do |t|
t.string "host" t.string "host"
t.boolean "ssl" t.boolean "ssl"