20181123000000_issue_2368_add_indices_to_histories_and_tickets.rb 777 B

12345678910111213
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class Issue2368AddIndicesToHistoriesAndTickets < ActiveRecord::Migration[5.1]
  3. def up
  4. return if !Setting.exists?(name: 'system_init_done')
  5. add_index :histories, :related_o_id if !index_exists?(:histories, :related_o_id)
  6. add_index :histories, :related_history_object_id if !index_exists?(:histories, :related_history_object_id)
  7. 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])
  8. add_index :tickets, %i[group_id state_id] if !index_exists?(:tickets, %i[group_id state_id])
  9. add_index :tickets, %i[group_id state_id owner_id] if !index_exists?(:tickets, %i[group_id state_id owner_id])
  10. end
  11. end