2017-09-08 08:28:34 +00:00
|
|
|
class UpdateTimestamps < ActiveRecord::Migration[4.2]
|
2015-09-27 21:01:45 +00:00
|
|
|
def up
|
|
|
|
# get all models
|
2017-10-01 12:25:52 +00:00
|
|
|
Models.all.each do |_model, value|
|
2015-09-27 21:01:45 +00:00
|
|
|
next if !value
|
|
|
|
next if !value[:attributes]
|
|
|
|
if value[:attributes].include?('changed_at')
|
|
|
|
ActiveRecord::Migration.change_column value[:table].to_sym, :changed_at, :datetime, null: false
|
|
|
|
end
|
|
|
|
if value[:attributes].include?('created_at')
|
|
|
|
ActiveRecord::Migration.change_column value[:table].to_sym, :created_at, :datetime, null: false
|
|
|
|
end
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2015-09-27 21:01:45 +00:00
|
|
|
end
|
|
|
|
end
|