2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-09-01 09:46:34 +00:00
|
|
|
|
|
|
|
class Issue3503FixCurrentUser < ActiveRecord::Migration[6.0]
|
|
|
|
def change
|
|
|
|
# return if it's a new setup
|
|
|
|
return if !Setting.exists?(name: 'system_init_done')
|
|
|
|
|
|
|
|
remove_current_user(Job)
|
|
|
|
remove_current_user(Sla)
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove_current_user(target)
|
|
|
|
target.find_each do |row|
|
|
|
|
row.condition.each do |key, condition|
|
|
|
|
next if condition['pre_condition'].blank?
|
|
|
|
next if condition['pre_condition'].exclude?('current_user')
|
|
|
|
|
|
|
|
row.condition.delete(key)
|
|
|
|
row.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|