20140730005210_convert_efa_skip_created_at.rb 681 B

123456789101112131415161718192021
  1. class ConvertEfaSkipCreatedAt < 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_created_at').to_s == 'true'
  6. agent.options['instructions'] = {
  7. 'created_at' => '{{created_at}}'
  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_created_at'] = (agent.options['instructions'] || {})['created_at'] == '{{created_at}}'
  17. agent.save!
  18. end
  19. end
  20. end