trabajo-afectivo/db/migrate/20210830150400_issue_3503_fix_current_user.rb

24 lines
613 B
Ruby
Raw Normal View History

# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
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