From a773a4d366ba0eb5c5f334103f682ce15fa52056 Mon Sep 17 00:00:00 2001 From: Adam Ferguson Date: Tue, 3 Apr 2012 15:23:14 -0400 Subject: [PATCH] Add compound index on impressionable_type, message, impressionable_id --- .../active_record/templates/create_impressions_table.rb | 1 + upgrade_migrations/version_1_1_2.rb | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 upgrade_migrations/version_1_1_2.rb diff --git a/lib/generators/active_record/templates/create_impressions_table.rb b/lib/generators/active_record/templates/create_impressions_table.rb index e3fa7d5..5282380 100644 --- a/lib/generators/active_record/templates/create_impressions_table.rb +++ b/lib/generators/active_record/templates/create_impressions_table.rb @@ -14,6 +14,7 @@ class CreateImpressionsTable < ActiveRecord::Migration t.text :referrer t.timestamps 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, :ip_address], :name => "poly_ip_index", :unique => false add_index :impressions, [:impressionable_type, :impressionable_id, :session_hash], :name => "poly_session_index", :unique => false diff --git a/upgrade_migrations/version_1_1_2.rb b/upgrade_migrations/version_1_1_2.rb new file mode 100644 index 0000000..1157327 --- /dev/null +++ b/upgrade_migrations/version_1_1_2.rb @@ -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