From 38ed47cf1308a01ae082fb1468e11448c15eaff5 Mon Sep 17 00:00:00 2001 From: Ko Nagase Date: Mon, 9 Dec 2024 16:23:13 +0900 Subject: [PATCH 3/5] Use UTC time for datetime column value --- lib/tasks/extract_fixtures.rake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/tasks/extract_fixtures.rake b/lib/tasks/extract_fixtures.rake index 949faeeeb..5e4fc24ee 100644 --- a/lib/tasks/extract_fixtures.rake +++ b/lib/tasks/extract_fixtures.rake @@ -34,9 +34,14 @@ task :extract_fixtures => :environment do data = ActiveRecord::Base.connection.select_all(sql) file.write data.inject({}) { |hash, record| # cast extracted values - columns.each { |col| - record[col.name] = ActiveRecord::Type.lookup(col.type).deserialize(record[col.name]) if record[col.name] - } + columns.each do |col| + if record[col.name] + record[col.name] = ActiveRecord::Type.lookup(col.type).deserialize(record[col.name]) + if col.type == :datetime && record[col.name].is_a?(Time) + record[col.name] = record[col.name].getutc + end + end + end hash["#{table_name}_#{i.succ!}"] = record hash }.to_yaml -- 2.47.1