impress/db/migrate/20120321222001_index_closet_hanger_query.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

22 lines
910 B
Ruby

class IndexClosetHangerQuery < ActiveRecord::Migration[3.2]
def self.up
# SELECT COUNT(DISTINCT `closet_hangers`.`id`) FROM `closet_hangers` INNER
# JOIN `users` ON `users`.`id` = `closet_hangers`.`user_id` LEFT OUTER JOIN
# `closet_lists` ON `closet_lists`.`id` = `closet_hangers`.`list_id` WHERE
# `closet_hangers`.`owned` = XXX AND (`closet_hangers`.item_id = XXX) AND
# ((`closet_hangers`.`list_id` IS NULL AND
# `users`.`owned_closet_hangers_visibility` >= XXX OR
# `closet_lists`.`visibility` >= XXX));
# It's not a huge improvement over the association index, but it's nice to
# be able to scan fewer rows for so little penalty, right?
remove_index :closet_hangers, :item_id
add_index :closet_hangers, [:item_id, :owned]
end
def self.down
remove_index :closet_hangers, [:item_id, :owned]
add_index :closet_hangers, :item_id
end
end