20150979000001_update_timestamps.rb 525 B

12345678910111213141516
  1. class UpdateTimestamps < ActiveRecord::Migration[4.2]
  2. def up
  3. # get all models
  4. Models.all.each_value do |value|
  5. next if !value
  6. next if !value[:attributes]
  7. if value[:attributes].include?('changed_at')
  8. ActiveRecord::Migration.change_column value[:table].to_sym, :changed_at, :datetime, null: false
  9. end
  10. if value[:attributes].include?('created_at')
  11. ActiveRecord::Migration.change_column value[:table].to_sym, :created_at, :datetime, null: false
  12. end
  13. end
  14. end
  15. end