]> git.openstreetmap.org Git - rails.git/blob - db/migrate/20180204153242_tile_users.rb
Be more consistent with 'my' vs 'your' for objects that belong to
[rails.git] / db / migrate / 20180204153242_tile_users.rb
1 class TileUsers < ActiveRecord::Migration[5.1]
2   def up
3     add_column :users, :home_tile, :bigint
4     add_index :users, [:home_tile], :name => "users_home_idx"
5
6     if ENV["USE_DB_FUNCTIONS"]
7       User.update_all("home_tile = tile_for_point(cast(round(home_lat * #{GeoRecord::SCALE}) as integer), cast(round(home_lon * #{GeoRecord::SCALE}) as integer))")
8     else
9       User.all.each(&:save!)
10     end
11   end
12
13   def down
14     remove_index :users, :name => "users_home_idx"
15     remove_column :users, :home_tile
16   end
17 end