X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/9afb35449b066fdef6b4af3b63e30e7f4eb4c5cf..58082d128a9eef5037c5b46e17ff59715a9bd6e8:/db/migrate/005_tile_tracepoints.rb diff --git a/db/migrate/005_tile_tracepoints.rb b/db/migrate/005_tile_tracepoints.rb index c0e6d8a61..51a4d1376 100644 --- a/db/migrate/005_tile_tracepoints.rb +++ b/db/migrate/005_tile_tracepoints.rb @@ -4,10 +4,20 @@ class TileTracepoints < ActiveRecord::Migration add_index "gps_points", ["tile"], :name => "points_tile_idx" remove_index "gps_points", :name => "points_idx" - Tracepoint.update_all("latitude = latitude * 10, longitude = longitude * 10, tile = tile_for_point(latitude * 10, longitude * 10)") + begin + Tracepoint.update_all("latitude = latitude * 10, longitude = longitude * 10, tile = tile_for_point(latitude * 10, longitude * 10)") + rescue ActiveRecord::StatementInvalid => ex + Tracepoint.find(:all).each do |tp| + tp.latitude = tp.latitude * 10 + tp.longitude = tp.longitude * 10 + tp.save! + end + end end def self.down + Tracepoint.update_all("latitude = latitude / 10, longitude = longitude / 10") + add_index "gps_points", ["latitude", "longitude"], :name => "points_idx" remove_index "gps_points", :name => "points_tile_idx" remove_column "gps_points", "tile"