diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/db/migrate/20180625074738_convert_timestamps_to_with_time_zone.rb	Mon Jun 25 16:53:47 2018 +0900
@@ -0,0 +1,26 @@
+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