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

16 lines
518 B
Ruby
Raw Normal View History

2015-09-27 21:01:45 +00:00
class UpdateTimestamps < ActiveRecord::Migration
def up
# get all models
2016-06-30 20:04:48 +00:00
Models.all.each { |_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
}
end
end