X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/2dd9538183f7f96023ddf221f10b4823f3189a44..5cc8afd896ee2c8f138c955844cdca6e618a7efa:/db/migrate/001_create_osm_db.rb diff --git a/db/migrate/001_create_osm_db.rb b/db/migrate/001_create_osm_db.rb index a9eeec814..2c80dd8ad 100644 --- a/db/migrate/001_create_osm_db.rb +++ b/db/migrate/001_create_osm_db.rb @@ -1,44 +1,7 @@ -module ActiveRecord - module ConnectionAdapters - module SchemaStatements - def add_primary_key(table_name, column_name, options = {}) - index_name = options[:name] - column_names = Array(column_name) - quoted_column_names = column_names.map { |e| quote_column_name(e) }.join(", ") - execute "ALTER TABLE #{table_name} ADD PRIMARY KEY #{quote_column_name(index_name)} (#{quoted_column_names})" - end - - alias_method :old_add_column_options!, :add_column_options! - - def add_column_options!(sql, options) - old_add_column_options!(sql, options) - sql << " #{options[:options]}" - end - - alias_method :old_options_include_default?, :options_include_default? - - def options_include_default?(options) - old_options_include_default?(options) && !(options[:options] =~ /AUTO_INCREMENT/i) - end - end - - class MysqlAdapter - alias_method :old_native_database_types, :native_database_types - - def native_database_types - types = old_native_database_types - types[:bigint] = { :name => "bigint", :limit => 20 } - types - end - end - end -end +require 'lib/migrate' class CreateOsmDb < ActiveRecord::Migration def self.up - myisam_table = { :id => false, :force => true, :options => "ENGINE=MyIsam DEFAULT CHARSET=utf8" } - innodb_table = { :id => false, :force => true, :options => "ENGINE=InnoDB DEFAULT CHARSET=utf8" } - create_table "current_nodes", innodb_table do |t| t.column "id", :bigint, :limit => 64, :null => false t.column "latitude", :double @@ -96,7 +59,7 @@ class CreateOsmDb < ActiveRecord::Migration t.column "visible", :boolean end - add_primary_key "current_ways", ["id"], :name => "current_ways_id_idx", :unique => true + add_primary_key "current_ways", ["id"] change_column "current_ways", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT" @@ -109,7 +72,7 @@ class CreateOsmDb < ActiveRecord::Migration t.column "updated_at", :datetime end - add_primary_key "diary_entries", ["id"], :name => "diary_entries_id_idx", :unique => true + add_primary_key "diary_entries", ["id"] change_column "diary_entries", "id", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT" @@ -119,7 +82,7 @@ class CreateOsmDb < ActiveRecord::Migration t.column "friend_user_id", :bigint, :limit => 20, :null => false end - add_primary_key "friends", ["id"], :name => "friends_id_idx", :unique => true + add_primary_key "friends", ["id"] add_index "friends", ["friend_user_id"], :name => "user_id_idx" change_column "friends", "id", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT" @@ -144,7 +107,7 @@ class CreateOsmDb < ActiveRecord::Migration t.column "id", :integer, :limit => 20, :null => false end - add_primary_key "gpx_file_tags", ["id"], :name => "gpx_file_tags_id_idx", :unique => true + add_primary_key "gpx_file_tags", ["id"] add_index "gpx_file_tags", ["gpx_id"], :name => "gpx_file_tags_gpxid_idx" change_column "gpx_file_tags", "id", :integer, :limit => 20, :null => false, :options => "AUTO_INCREMENT" @@ -163,7 +126,7 @@ class CreateOsmDb < ActiveRecord::Migration t.column "inserted", :boolean end - add_primary_key "gpx_files", ["id"], :name => "gpx_files_id_idx", :unique => true + add_primary_key "gpx_files", ["id"] add_index "gpx_files", ["timestamp"], :name => "gpx_files_timestamp_idx" add_index "gpx_files", ["visible", "public"], :name => "gpx_files_visible_public_idx" @@ -187,7 +150,7 @@ class CreateOsmDb < ActiveRecord::Migration t.column "to_user_id", :bigint, :limit => 20, :null => false end - add_primary_key "messages", ["id"], :name => "messages_id_idx", :unique => true + add_primary_key "messages", ["id"] add_index "messages", ["from_display_name"], :name => "from_name_idx" change_column "messages", "id", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT" @@ -198,7 +161,7 @@ class CreateOsmDb < ActiveRecord::Migration t.column "timestamp", :datetime end - add_primary_key "meta_areas", ["id"], :name => "meta_areas_id_idx", :unique => true + add_primary_key "meta_areas", ["id"] change_column "meta_areas", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT" @@ -248,7 +211,7 @@ class CreateOsmDb < ActiveRecord::Migration t.column "home_zoom", :integer, :limit => 2, :default => 3 end - add_primary_key "users", ["id"], :name => "users_id_idx", :unique => true + add_primary_key "users", ["id"] add_index "users", ["email"], :name => "users_email_idx" add_index "users", ["display_name"], :name => "users_display_name_idx" @@ -261,7 +224,7 @@ class CreateOsmDb < ActiveRecord::Migration t.column "sequence_id", :bigint, :limit => 11, :null => false end - add_primary_key "way_segments", ["id", "version", "sequence_id"], :name => "way_segments_id_version_sequence_idx", :unique => true + add_primary_key "way_segments", ["id", "version", "sequence_id"] change_column "way_segments", "sequence_id", :bigint, :limit => 11, :null => false, :options => "AUTO_INCREMENT" @@ -282,7 +245,7 @@ class CreateOsmDb < ActiveRecord::Migration t.column "visible", :boolean, :default => true end - add_primary_key "ways", ["id", "version"], :name => "ways_primary_idx", :unique => true + add_primary_key "ways", ["id", "version"] add_index "ways", ["id"], :name => "ways_id_version_idx" change_column "ways", "version", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT"