add indexes to impressions table
This commit is contained in:
parent
17558312c4
commit
22e83c58ba
|
@ -12,9 +12,16 @@ class CreateImpressionsTable < ActiveRecord::Migration
|
||||||
t.string :message
|
t.string :message
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
add_index :impressions, [:impressionable_type, :impressionable_id, :request_hash, :ip_address], :name => "poly_index", :unique => false
|
||||||
|
add_index :impressions, [:controller_name,:action_name,:request_hash,:ip_address], :name => "controlleraction_index", :unique => false
|
||||||
|
add_index :impressions, :user_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
|
remove_index :impressions, :name => :poly_index
|
||||||
|
remove_index :impressions, :name => :controlleraction_index
|
||||||
|
remove_index :impressions, :user_id
|
||||||
|
|
||||||
drop_table :impressions
|
drop_table :impressions
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,7 +1,7 @@
|
||||||
PATH
|
PATH
|
||||||
remote: /rails_plugins/mine/impressionist
|
remote: /rails_plugins/mine/impressionist
|
||||||
specs:
|
specs:
|
||||||
impressionist (0.1.2)
|
impressionist (0.2.0)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
require 'systemu'
|
||||||
|
|
||||||
|
describe Impressionist do
|
||||||
|
it "should delete existing migration and generate the migration file" do
|
||||||
|
migrations_dir = "#{Rails.root}/db/migrate"
|
||||||
|
impressions_migration = Dir.entries(migrations_dir).grep(/impressions/)[0]
|
||||||
|
File.delete("#{migrations_dir}/#{impressions_migration}") unless impressions_migration.blank?
|
||||||
|
generator_output = systemu("rails g impressionist")[1]
|
||||||
|
migration_name = generator_output.split("migrate/")[1].strip
|
||||||
|
Dir.entries(migrations_dir).include?(migration_name).should be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should run the migration created in the previous spec" do
|
||||||
|
migrate_output = systemu("rake db:migrate")
|
||||||
|
migrate_output[1].include?("CreateImpressionsTable: migrated").should be true
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue