annotate db/migrate/20180625074738_convert_timestamps_to_with_time_zone.rb @ 499:d2ef59c9a4b4

Use rails rubocop
author nanaya <me@nanaya.net>
date Sun, 15 Dec 2024 22:33:27 +0900
parents b1ef80121c79
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
460
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
1 class ConvertTimestampsToWithTimeZone < ActiveRecord::Migration[5.2]
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
2 COLUMNS = {
499
d2ef59c9a4b4 Use rails rubocop
nanaya <me@nanaya.net>
parents: 460
diff changeset
3 ar_internal_metadata: [ :created_at, :updated_at ],
d2ef59c9a4b4 Use rails rubocop
nanaya <me@nanaya.net>
parents: 460
diff changeset
4 pastes: [ :created_at, :updated_at ]
460
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
5 }
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
6
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
7 def up
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
8 COLUMNS.each do |table, columns|
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
9 change_table table do |t|
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
10 columns.each do |column|
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
11 t.change column, :timestamptz
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
12 end
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
13 end
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
14 end
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
15 end
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
16
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
17 def down
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
18 COLUMNS.each do |table, columns|
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
19 change_table table do |t|
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
20 columns.each do |column|
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
21 t.change column, :timestamp
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
22 end
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
23 end
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
24 end
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
25 end
b1ef80121c79 Update to use correct timestamp datatype
nanaya <me@nanaya.pro>
parents:
diff changeset
26 end