20200510181721_remove_duplicated_indexes_pghero.rb 2.8 KB

12345678910111213141516171819202122
  1. class RemoveDuplicatedIndexesPghero < ActiveRecord::Migration[5.2]
  2. def up
  3. remove_index :account_conversations, name: :index_account_conversations_on_account_id if index_exists?(:account_conversations, :account_id, name: :index_account_conversations_on_account_id)
  4. remove_index :account_identity_proofs, name: :index_account_identity_proofs_on_account_id if index_exists?(:account_identity_proofs, :account_id, name: :index_account_identity_proofs_on_account_id)
  5. remove_index :account_pins, name: :index_account_pins_on_account_id if index_exists?(:account_pins, :account_id, name: :index_account_pins_on_account_id)
  6. remove_index :announcement_mutes, name: :index_announcement_mutes_on_account_id if index_exists?(:announcement_mutes, :account_id, name: :index_announcement_mutes_on_account_id)
  7. remove_index :announcement_reactions, name: :index_announcement_reactions_on_account_id if index_exists?(:announcement_reactions, :account_id, name: :index_announcement_reactions_on_account_id)
  8. remove_index :bookmarks, name: :index_bookmarks_on_account_id if index_exists?(:bookmarks, :account_id, name: :index_bookmarks_on_account_id)
  9. remove_index :markers, name: :index_markers_on_user_id if index_exists?(:markers, :user_id, name: :index_markers_on_user_id)
  10. end
  11. def down
  12. add_index :account_conversations, :account_id, name: :index_account_conversations_on_account_id unless index_exists?(:account_conversations, :account_id, name: :index_account_conversations_on_account_id)
  13. add_index :account_identity_proofs, :account_id, name: :index_account_identity_proofs_on_account_id unless index_exists?(:account_identity_proofs, :account_id, name: :index_account_identity_proofs_on_account_id)
  14. add_index :account_pins, :account_id, name: :index_account_pins_on_account_id unless index_exists?(:account_pins, :account_id, name: :index_account_pins_on_account_id)
  15. add_index :announcement_mutes, :account_id, name: :index_announcement_mutes_on_account_id unless index_exists?(:announcement_mutes, :account_id, name: :index_announcement_mutes_on_account_id)
  16. add_index :announcement_reactions, :account_id, name: :index_announcement_reactions_on_account_id unless index_exists?(:announcement_reactions, :account_id, name: :index_announcement_reactions_on_account_id)
  17. add_index :bookmarks, :account_id, name: :index_bookmarks_on_account_id unless index_exists?(:bookmarks, :account_id, name: :index_bookmarks_on_account_id)
  18. add_index :markers, :user_id, name: :index_markers_on_user_id unless index_exists?(:markers, :user_id, name: :index_markers_on_user_id)
  19. end
  20. end