impress/db/migrate/20120321231507_index_closet_hanger_query2.rb
Matchu b2a027fbbf Oops, should've used migration version 4.2
Oh I didn't realize the lowest version Rails had for this is 4.2. I wish running `rake db:migrate` checked this, but I'm running into it on another branch when I try to create a *new* migration which for some reason leads it to inspect the old migrations and notice the issue. Weird!
2023-10-23 19:05:08 -07:00

20 lines
833 B
Ruby

class IndexClosetHangerQuery2 < ActiveRecord::Migration[4.2]
def self.up
# SELECT `objects`.* FROM `objects`
# INNER JOIN `item_outfit_relationships` ON
# `objects`.id = `item_outfit_relationships`.item_id
# WHERE ((`item_outfit_relationships`.outfit_id = 138510) AND
# ((`item_outfit_relationships`.`is_worn` = 1)));
# Small optimization, but an optimization nonetheless!
# Note that MySQL indexes can be reused for left-subsets, by which I mean
# this index can also act as just an index for outfit_id. Neat, eh?
remove_index :item_outfit_relationships, :outfit_id
add_index :item_outfit_relationships, [:outfit_id, :is_worn]
end
def self.down
remove_index :item_outfit_relationships, [:outfit_id, :is_worn]
add_index :item_outfit_relationships, :outfit_id
end
end