20170731191002_migrate_growl_agent_to_liquid.rb 554 B

123456789101112131415161718
  1. class MigrateGrowlAgentToLiquid < ActiveRecord::Migration[5.1]
  2. def up
  3. Agents::GrowlAgent.find_each do |agent|
  4. agent.options['subject'] = '{{subject}}' if agent.options['subject'].blank?
  5. agent.options['message'] = '{{ message | default: text }}' if agent.options['message'].blank?
  6. agent.save(validate: false)
  7. end
  8. end
  9. def down
  10. Agents::GrowlAgent.find_each do |agent|
  11. %w(subject message sticky priority).each do |key|
  12. agent.options.delete(key)
  13. end
  14. agent.save(validate: false)
  15. end
  16. end
  17. end