Mercurial > zeropaste
comparison db/migrate/20180625074738_convert_timestamps_to_with_time_zone.rb @ 460:b1ef80121c79
Update to use correct timestamp datatype
Use sql dump instead of ruby because zone info would be lost otherwise.
author | nanaya <me@nanaya.pro> |
---|---|
date | Mon, 25 Jun 2018 16:53:47 +0900 |
parents | |
children | d2ef59c9a4b4 |
comparison
equal
deleted
inserted
replaced
459:07d6c6639adf | 460:b1ef80121c79 |
---|---|
1 class ConvertTimestampsToWithTimeZone < ActiveRecord::Migration[5.2] | |
2 COLUMNS = { | |
3 ar_internal_metadata: [:created_at, :updated_at], | |
4 pastes: [:created_at, :updated_at], | |
5 } | |
6 | |
7 def up | |
8 COLUMNS.each do |table, columns| | |
9 change_table table do |t| | |
10 columns.each do |column| | |
11 t.change column, :timestamptz | |
12 end | |
13 end | |
14 end | |
15 end | |
16 | |
17 def down | |
18 COLUMNS.each do |table, columns| | |
19 change_table table do |t| | |
20 columns.each do |column| | |
21 t.change column, :timestamp | |
22 end | |
23 end | |
24 end | |
25 end | |
26 end |