20210830150400_issue_3503_fix_current_user.rb 614 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class Issue3503FixCurrentUser < ActiveRecord::Migration[6.0]
  3. def change
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. remove_current_user(Job)
  7. remove_current_user(Sla)
  8. end
  9. def remove_current_user(target)
  10. target.find_each do |row|
  11. row.condition.each do |key, condition|
  12. next if condition['pre_condition'].blank?
  13. next if condition['pre_condition'].exclude?('current_user')
  14. row.condition.delete(key)
  15. row.save
  16. end
  17. end
  18. end
  19. end