20190314084909_object_manager_attribute_date_remove_future_past.rb 676 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ObjectManagerAttributeDateRemoveFuturePast < ActiveRecord::Migration[5.1]
  3. def change
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. ObjectManager::Attribute.where(data_type: 'date').each do |attribute|
  7. attribute.data_option = attribute.data_option.except(:future, :past)
  8. # some attributes from the early Zammad days don't have all
  9. # required data_option attributes because they were not properly migrated
  10. # so we need to fix them now
  11. attribute.data_option[:diff] ||= 24
  12. attribute.save!
  13. end
  14. end
  15. end