Add compound index on impressionable_type, message, impressionable_id

This commit is contained in:
Adam Ferguson 2012-04-03 15:23:14 -04:00
parent 63ea4d5663
commit a773a4d366
2 changed files with 10 additions and 0 deletions

View File

@ -14,6 +14,7 @@ class CreateImpressionsTable < ActiveRecord::Migration
t.text :referrer t.text :referrer
t.timestamps t.timestamps
end end
add_index :impressions, [:impressionable_type, :message, :impressionable_id], :name => "impressionable_type_message_index", :unique => false
add_index :impressions, [:impressionable_type, :impressionable_id, :request_hash], :name => "poly_request_index", :unique => false add_index :impressions, [:impressionable_type, :impressionable_id, :request_hash], :name => "poly_request_index", :unique => false
add_index :impressions, [:impressionable_type, :impressionable_id, :ip_address], :name => "poly_ip_index", :unique => false add_index :impressions, [:impressionable_type, :impressionable_id, :ip_address], :name => "poly_ip_index", :unique => false
add_index :impressions, [:impressionable_type, :impressionable_id, :session_hash], :name => "poly_session_index", :unique => false add_index :impressions, [:impressionable_type, :impressionable_id, :session_hash], :name => "poly_session_index", :unique => false

View File

@ -0,0 +1,9 @@
class Version04UpdateImpressionsTable < ActiveRecord::Migration
def self.up
add_index :impressions, [:impressionable_type, :message, :impressionable_id], :name => "impressionable_type_message_index", :unique => false
end
def self.down
remove_column :impressions, :impressionable_type_message_index
end
end