1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 23:59:40 +02:00
Maybe/db/migrate/20250623162207_update_outdated_timezones.rb
Josh Pigford c0617f74cd
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions
Fix linting issues in migration file
2025-06-23 11:31:57 -05:00

31 lines
797 B
Ruby

class UpdateOutdatedTimezones < ActiveRecord::Migration[7.2]
TIMEZONE_MAPPINGS = {
"Europe/Kiev" => "Europe/Kyiv",
"Asia/Calcutta" => "Asia/Kolkata",
"Asia/Katmandu" => "Asia/Kathmandu",
"Asia/Rangoon" => "Asia/Yangon",
"Asia/Saigon" => "Asia/Ho_Chi_Minh",
"Pacific/Ponape" => "Pacific/Pohnpei",
"Pacific/Truk" => "Pacific/Chuuk"
}.freeze
def up
TIMEZONE_MAPPINGS.each do |old_tz, new_tz|
execute <<-SQL
UPDATE families#{' '}
SET timezone = '#{new_tz}'#{' '}
WHERE timezone = '#{old_tz}'
SQL
end
end
def down
TIMEZONE_MAPPINGS.each do |old_tz, new_tz|
execute <<-SQL
UPDATE families#{' '}
SET timezone = '#{old_tz}'#{' '}
WHERE timezone = '#{new_tz}'
SQL
end
end
end