20211020131134_issue_3810_custom_date_attribute_no_default.rb 465 B

123456789101112131415161718
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Issue3810CustomDateAttributeNoDefault < ActiveRecord::Migration[6.0]
  3. def up
  4. return if !Setting.exists?(name: 'system_init_done')
  5. ObjectManager::Attribute
  6. .where(data_type: %i[date datetime])
  7. .each { |elem| update_single(elem) }
  8. end
  9. def update_single(elem)
  10. elem.data_option[:diff] = nil
  11. elem.save!
  12. rescue => e
  13. Rails.logger.error e
  14. end
  15. end