trabajo-afectivo/db/migrate/20190314084909_object_manager_attribute_date_remove_future_past.rb

19 lines
599 B
Ruby
Raw Normal View History

class ObjectManagerAttributeDateRemoveFuturePast < ActiveRecord::Migration[5.1]
def change
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
ObjectManager::Attribute.where(data_type: 'date').each do |attribute|
attribute.data_option = attribute.data_option.except(:future, :past)
# some attributes from the early Zammad days don't have all
# required data_option attributes because they were not properly migrated
# so we need to fix them now
attribute.data_option[:diff] ||= 24
attribute.save!
end
end
end