aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrate/20170808091929_change_objectid_suffix.rb
blob: da98e8b9d7c1ae63fecfe86d1350af3e94f9c72c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class ChangeObjectidSuffix < ActiveRecord::Migration
  def tables
    ['routes', 'journey_patterns', 'vehicle_journeys', 'time_tables', 'routing_constraint_zones']
  end

  def up
    self.tables.each do |table|
      execute "UPDATE #{table} SET objectid = (objectid || ':LOC')"
    end
  end

  def down
    self.tables.each do |table|
      execute "UPDATE #{table} SET objectid = replace(objectid, ':LOC', '')"
    end
  end
end