20231129085408_drop_removed_state.rb 485 B

12345678910111213141516171819
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class DropRemovedState < ActiveRecord::Migration[7.0]
  3. def change
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. state_type = Ticket::StateType.find_by(name: 'removed')
  7. return if !state_type
  8. states = state_type.states
  9. return if states.empty?
  10. return if Ticket.exists?(state: states)
  11. states.each(&:delete)
  12. state_type.delete
  13. end
  14. end