20181123000000_issue_2368_add_indices_to_histories_and_tickets.rb 700 B

1234567891011
  1. class Issue2368AddIndicesToHistoriesAndTickets < ActiveRecord::Migration[5.1]
  2. def up
  3. return if !Setting.find_by(name: 'system_init_done')
  4. add_index :histories, :related_o_id if !index_exists?(:histories, :related_o_id)
  5. add_index :histories, :related_history_object_id if !index_exists?(:histories, :related_history_object_id)
  6. add_index :histories, %i[o_id history_object_id related_o_id] if !index_exists?(:histories, %i[o_id history_object_id related_o_id])
  7. add_index :tickets, %i[group_id state_id] if !index_exists?(:tickets, %i[group_id state_id])
  8. add_index :tickets, %i[group_id state_id owner_id] if !index_exists?(:tickets, %i[group_id state_id owner_id])
  9. end
  10. end