1 class TileUsers < ActiveRecord::Migration[5.1]
2 class User < ActiveRecord::Base
6 add_column :users, :home_tile, :bigint
7 add_index :users, [:home_tile], :name => "users_home_idx"
9 if ENV["USE_DB_FUNCTIONS"]
10 User.update_all("home_tile = tile_for_point(cast(round(home_lat * #{GeoRecord::SCALE}) as integer), cast(round(home_lon * #{GeoRecord::SCALE}) as integer))")
12 User.all.each(&:save!)
17 remove_index :users, :name => "users_home_idx"
18 remove_column :users, :home_tile