trabajo-afectivo/db/migrate/20150979000001_update_timestamps.rb

22 lines
713 B
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
2017-09-08 08:28:34 +00:00
class UpdateTimestamps < ActiveRecord::Migration[4.2]
2015-09-27 21:01:45 +00:00
def up
# return if it's a new setup
return if !Setting.exists?(name: 'system_init_done')
2015-09-27 21:01:45 +00:00
# get all models
2017-11-23 08:09:44 +00:00
Models.all.each_value do |value|
2015-09-27 21:01:45 +00:00
next if !value
next if !value[:attributes]
if value[:attributes].include?('updated_at')
ActiveRecord::Migration.change_column value[:table].to_sym, :updated_at, :datetime, limit: 3, null: false
2015-09-27 21:01:45 +00:00
end
if value[:attributes].include?('created_at')
ActiveRecord::Migration.change_column value[:table].to_sym, :created_at, :datetime, limit: 3, null: false
2015-09-27 21:01:45 +00:00
end
end
2015-09-27 21:01:45 +00:00
end
end