view db/migrate/20180625074738_convert_timestamps_to_with_time_zone.rb @ 505:7236c8864ad2

Remove ZP_ prefix from environment variable names
author nanaya <me@nanaya.net>
date Mon, 16 Dec 2024 01:42:54 +0900
parents d2ef59c9a4b4
children
line wrap: on
line source

class ConvertTimestampsToWithTimeZone < ActiveRecord::Migration[5.2]
  COLUMNS = {
    ar_internal_metadata: [ :created_at, :updated_at ],
    pastes: [ :created_at, :updated_at ]
  }

  def up
    COLUMNS.each do |table, columns|
      change_table table do |t|
        columns.each do |column|
          t.change column, :timestamptz
        end
      end
    end
  end

  def down
    COLUMNS.each do |table, columns|
      change_table table do |t|
        columns.each do |column|
          t.change column, :timestamp
        end
      end
    end
  end
end