20150979000001_update_timestamps.rb 713 B

123456789101112131415161718192021
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class UpdateTimestamps < ActiveRecord::Migration[4.2]
  3. def up
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. # get all models
  7. Models.all.each_value do |value|
  8. next if !value
  9. next if !value[:attributes]
  10. if value[:attributes].include?('updated_at')
  11. ActiveRecord::Migration.change_column value[:table].to_sym, :updated_at, :datetime, limit: 3, null: false
  12. end
  13. if value[:attributes].include?('created_at')
  14. ActiveRecord::Migration.change_column value[:table].to_sym, :created_at, :datetime, limit: 3, null: false
  15. end
  16. end
  17. end
  18. end