20240716075304_issue5147_modified_operator.rb 755 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Issue5147ModifiedOperator < 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. map_operator = {
  7. 'has changed' => 'just changed',
  8. 'changed to' => 'just changed to',
  9. }
  10. CoreWorkflow.find_each do |core_workflow|
  11. %i[condition_saved condition_selected].each do |column|
  12. core_workflow[column].each do |key, value|
  13. next if value.blank?
  14. next if map_operator.keys.exclude?(value[:operator])
  15. core_workflow[column][key][:operator] = map_operator[value[:operator]]
  16. end
  17. end
  18. core_workflow.save!
  19. end
  20. end
  21. end