diff options
| author | Zog | 2018-04-25 15:34:57 +0200 | 
|---|---|---|
| committer | Alban Peignier | 2018-04-25 22:44:51 +0200 | 
| commit | 0e64912dd2c299df543ed03e2cd6609bc7d6dec6 (patch) | |
| tree | e9fa08b24b8c231d4671bfc15a7e3c59ffc66950 /db | |
| parent | b930761de0a269c45876b2242e085e23070f8325 (diff) | |
| download | chouette-core-0e64912dd2c299df543ed03e2cd6609bc7d6dec6.tar.bz2 | |
Refs #6683; Uniformize the time_zones notation
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrate/20180425133154_fix_timezones.rb | 19 | 
1 files changed, 19 insertions, 0 deletions
| diff --git a/db/migrate/20180425133154_fix_timezones.rb b/db/migrate/20180425133154_fix_timezones.rb new file mode 100644 index 000000000..0e9e5fcb3 --- /dev/null +++ b/db/migrate/20180425133154_fix_timezones.rb @@ -0,0 +1,19 @@ +class FixTimezones < ActiveRecord::Migration +  def convert tz +    return unless tz.present? +    return tz unless ActiveSupport::TimeZone[tz].present? +    ActiveSupport::TimeZone[tz].tzinfo.name +  end + +  def change +    if Apartment::Tenant.current == "public" +      Chouette::StopArea.where.not("time_zone LIKE '%/%'").find_each do |s| +        s.update time_zone: convert(s.time_zone) +      end + +      Chouette::Company.where.not("time_zone LIKE '%/%'").find_each do |c| +        c.update time_zone: convert(c.time_zone) +      end +    end +  end +end | 
