20200510181721_remove_duplicated_indexes_pghero.rb 2.8 KB

1234567891011121314151617181920212223
  1. # frozen_string_literal: true
  2. class RemoveDuplicatedIndexesPghero < ActiveRecord::Migration[5.2]
  3. def up
  4. 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)
  5. 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)
  6. 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)
  7. 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)
  8. 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)
  9. remove_index :bookmarks, name: :index_bookmarks_on_account_id if index_exists?(:bookmarks, :account_id, name: :index_bookmarks_on_account_id)
  10. remove_index :markers, name: :index_markers_on_user_id if index_exists?(:markers, :user_id, name: :index_markers_on_user_id)
  11. end
  12. def down
  13. 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)
  14. 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)
  15. 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)
  16. 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)
  17. 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)
  18. add_index :bookmarks, :account_id, name: :index_bookmarks_on_account_id unless index_exists?(:bookmarks, :account_id, name: :index_bookmarks_on_account_id)
  19. add_index :markers, :user_id, name: :index_markers_on_user_id unless index_exists?(:markers, :user_id, name: :index_markers_on_user_id)
  20. end
  21. end