1 class TileTracepoints < ActiveRecord::Migration[4.2]
2 class Tracepoint < ApplicationRecord
3 self.table_name = "gps_points"
7 add_column "gps_points", "tile", :bigint
8 add_index "gps_points", ["tile"], :name => "points_tile_idx"
9 remove_index "gps_points", :name => "points_idx"
11 if ENV["USE_DB_FUNCTIONS"]
12 Tracepoint.update_all("latitude = latitude * 10, longitude = longitude * 10, tile = tile_for_point(latitude * 10, longitude * 10)")
14 Tracepoint.all.each do |tp|
15 tp.latitude = tp.latitude * 10
16 tp.longitude = tp.longitude * 10
23 Tracepoint.update_all("latitude = latitude / 10, longitude = longitude / 10")
25 add_index "gps_points", %w[latitude longitude], :name => "points_idx"
26 remove_index "gps_points", :name => "points_tile_idx"
27 remove_column "gps_points", "tile"