1
0

20140722131220_convert_efa_skip_agent.rb 657 B

123456789101112131415161718192021
  1. class ConvertEfaSkipAgent < ActiveRecord::Migration
  2. def up
  3. Agent.where(type: 'Agents::EventFormattingAgent').each do |agent|
  4. agent.options_will_change!
  5. unless agent.options.delete('skip_agent').to_s == 'true'
  6. agent.options['instructions'] = {
  7. 'agent' => '{{agent.type}}'
  8. }.update(agent.options['instructions'] || {})
  9. end
  10. agent.save!
  11. end
  12. end
  13. def down
  14. Agent.where(type: 'Agents::EventFormattingAgent').each do |agent|
  15. agent.options_will_change!
  16. agent.options['skip_agent'] = (agent.options['instructions'] || {})['agent'] == '{{agent.type}}'
  17. agent.save!
  18. end
  19. end
  20. end