From: Andy Allan Date: Sun, 9 Nov 2008 19:30:22 +0000 (+0000) Subject: remove indexes before renaming tables (some dbs have database-level index namespaces... X-Git-Tag: live~7577^2~170 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/4adeeb51adaecbb1dddf07c0f5253de050963e35 remove indexes before renaming tables (some dbs have database-level index namespaces) and unsigned is also a mysqlism --- diff --git a/db/migrate/002_cleanup_osm_db.rb b/db/migrate/002_cleanup_osm_db.rb index f283602ac..b13a92099 100644 --- a/db/migrate/002_cleanup_osm_db.rb +++ b/db/migrate/002_cleanup_osm_db.rb @@ -39,7 +39,9 @@ class CleanupOsmDb < ActiveRecord::Migration add_index "friends", ["user_id"], :name => "friends_user_id_idx" remove_index "gps_points", :name => "points_uid_idx" + remove_index "gps_points", :name => "points_idx" remove_column "gps_points", "user_id" + add_index "gps_points", ["latitude", "longitude"], :name => "points_idx" change_column "gps_points", "trackid", :integer, :null => false change_column "gps_points", "latitude", :integer, :null => false change_column "gps_points", "longitude", :integer, :null => false diff --git a/db/migrate/005_tile_tracepoints.rb b/db/migrate/005_tile_tracepoints.rb index 51a4d1376..74d85d195 100644 --- a/db/migrate/005_tile_tracepoints.rb +++ b/db/migrate/005_tile_tracepoints.rb @@ -1,6 +1,6 @@ class TileTracepoints < ActiveRecord::Migration def self.up - add_column "gps_points", "tile", :integer, :null => false, :unsigned => true + add_column "gps_points", "tile", :four_byte_unsigned add_index "gps_points", ["tile"], :name => "points_tile_idx" remove_index "gps_points", :name => "points_idx" diff --git a/db/migrate/006_tile_nodes.rb b/db/migrate/006_tile_nodes.rb index f3a1edbb2..dc4755ac3 100644 --- a/db/migrate/006_tile_nodes.rb +++ b/db/migrate/006_tile_nodes.rb @@ -33,6 +33,8 @@ class TileNodes < ActiveRecord::Migration end def self.up + remove_index "current_nodes", :name => "current_nodes_timestamp_idx" + rename_table "current_nodes", "current_nodes_v5" create_table "current_nodes", innodb_table do |t| @@ -49,12 +51,14 @@ class TileNodes < ActiveRecord::Migration add_index "current_nodes", ["timestamp"], :name => "current_nodes_timestamp_idx" add_index "current_nodes", ["tile"], :name => "current_nodes_tile_idx" - change_column "current_nodes", "tile", :integer, :null => false, :unsigned => true + change_column "current_nodes", "tile", :four_byte_unsigned upgrade_table "current_nodes_v5", "current_nodes", Node drop_table "current_nodes_v5" + remove_index "nodes", :name=> "nodes_uid_idx" + remove_index "nodes", :name=> "nodes_timestamp_idx" rename_table "nodes", "nodes_v5" create_table "nodes", myisam_table do |t| @@ -72,7 +76,7 @@ class TileNodes < ActiveRecord::Migration add_index "nodes", ["timestamp"], :name => "nodes_timestamp_idx" add_index "nodes", ["tile"], :name => "nodes_tile_idx" - change_column "nodes", "tile", :integer, :null => false, :unsigned => true + change_column "nodes", "tile", :four_byte_unsigned upgrade_table "nodes_v5", "nodes", OldNode diff --git a/lib/migrate.rb b/lib/migrate.rb index 69538f1da..38f8db6b3 100644 --- a/lib/migrate.rb +++ b/lib/migrate.rb @@ -49,6 +49,7 @@ module ActiveRecord types[:bigint_auto_64] = { :name => "bigint(64) DEFAULT NULL auto_increment" } types[:bigint_auto_11] = { :name => "bigint(11) DEFAULT NULL auto_increment" } types[:bigint_auto_20] = { :name => "bigint(20) DEFAULT NULL auto_increment" } + types[:four_byte_unsigned] = { :name=> "integer unsigned NOT NULL" } types end