ref: master
db/migrate/046_aggressive_indexing_strategy1.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
class AggressiveIndexingStrategy1 < ActiveRecord::Migration def self.up # profile categorizations add_index(:categories_profiles, :profile_id) add_index(:categories_profiles, :category_id) # product categorizations add_index(:product_categorizations, :product_id) add_index(:product_categorizations, :category_id) # finding products by the enterprises that own them add_index(:products, :enterprise_id) # finding profiles by their environment add_index(:profiles, :environment_id) # finding blocks by their box, and boxes by their owner add_index(:blocks, :box_id) add_index(:boxes, [:owner_type, :owner_id]) end def self.down remove_index(:categories_profiles, :column => :profile_id) remove_index(:categories_profiles, :column => :category_id) remove_index(:product_categorizations, :column => :product_id) remove_index(:product_categorizations, :column => :category_id) remove_index(:products, :column => :enterprise_id) remove_index(:profiles, :column => :environment_id) remove_index(:blocks, :column => :box_id) remove_index(:boxes, :column => [:owner_type, :owner_id]) end end |