1
0
Fork 0
forked from OpenNeo/impress
impress/db/migrate/20120321231507_index_closet_hanger_query2.rb
Matchu fcf3292448 Add Rails version to old migrations
I'm not sure it's literally true that they were all built against Rails 3.2, but that's what it was at before we upgraded, and like. that's probably fine
2023-10-23 19:05:08 -07:00

20 lines
833 B
Ruby

class IndexClosetHangerQuery2 < ActiveRecord::Migration[3.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