20220707000001_template_migration.rb 641 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class TemplateMigration < ActiveRecord::Migration[6.0]
  3. def change
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. article_attribute_list = %w[body form_id]
  7. Template.all.each do |template|
  8. new_options = {}
  9. template.options.each do |key, value|
  10. new_key = "ticket.#{key}"
  11. if article_attribute_list.include?(key)
  12. new_key = "article.#{key}"
  13. end
  14. new_options[new_key] = value
  15. end
  16. template.options = new_options
  17. template.save!
  18. end
  19. end
  20. end