X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/f042a797c65fc96e79c2618e8653fbfb6488b67d..d5356eb7d87b97d9562a035cf4ea70adbc5bef1b:/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 e5840b380..8ddc68bcd 100644 --- a/db/migrate/001_create_osm_db.rb +++ b/db/migrate/001_create_osm_db.rb @@ -1,10 +1,7 @@ -require 'lib/migrate' +require '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 @@ -19,7 +16,7 @@ class CreateOsmDb < ActiveRecord::Migration add_index "current_nodes", ["latitude", "longitude"], :name => "current_nodes_lat_lon_idx" add_index "current_nodes", ["timestamp"], :name => "current_nodes_timestamp_idx" - change_column "current_nodes", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT" + change_column :current_nodes, :id, :bigint_auto_64 create_table "current_segments", innodb_table do |t| t.column "id", :bigint, :limit => 64, :null => false @@ -35,7 +32,7 @@ class CreateOsmDb < ActiveRecord::Migration add_index "current_segments", ["node_a"], :name => "current_segments_a_idx" add_index "current_segments", ["node_b"], :name => "current_segments_b_idx" - change_column "current_segments", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT" + change_column :current_segments, :id, :bigint_auto_64 create_table "current_way_segments", innodb_table do |t| t.column "id", :bigint, :limit => 64 @@ -53,21 +50,17 @@ class CreateOsmDb < ActiveRecord::Migration end add_index "current_way_tags", ["id"], :name => "current_way_tags_id_idx" - execute "CREATE FULLTEXT INDEX `current_way_tags_v_idx` ON `current_way_tags` (`v`)" + add_fulltext_index "current_way_tags", "v" create_table "current_ways", myisam_table do |t| - t.column "id", :bigint, :limit => 64, :null => false + t.column "id", :bigint_pk_64, :null => false t.column "user_id", :bigint, :limit => 20 t.column "timestamp", :datetime t.column "visible", :boolean end - add_primary_key "current_ways", ["id"], :name => "current_ways_id_idx", :unique => true - - change_column "current_ways", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT" - create_table "diary_entries", myisam_table do |t| - t.column "id", :bigint, :limit => 20, :null => false + t.column "id", :bigint_pk, :null => false t.column "user_id", :bigint, :limit => 20, :null => false t.column "title", :string t.column "body", :text @@ -75,21 +68,14 @@ class CreateOsmDb < ActiveRecord::Migration t.column "updated_at", :datetime end - add_primary_key "diary_entries", ["id"], :name => "diary_entries_id_idx", :unique => true - - change_column "diary_entries", "id", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT" - create_table "friends", myisam_table do |t| - t.column "id", :bigint, :limit => 20, :null => false + t.column "id", :bigint_pk, :null => false t.column "user_id", :bigint, :limit => 20, :null => false t.column "friend_user_id", :bigint, :limit => 20, :null => false end - add_primary_key "friends", ["id"], :name => "friends_id_idx", :unique => true add_index "friends", ["friend_user_id"], :name => "user_id_idx" - change_column "friends", "id", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT" - create_table "gps_points", myisam_table do |t| t.column "altitude", :float t.column "user_id", :integer, :limit => 20 @@ -107,16 +93,13 @@ class CreateOsmDb < ActiveRecord::Migration create_table "gpx_file_tags", myisam_table do |t| t.column "gpx_id", :bigint, :limit => 64, :default => 0, :null => false t.column "tag", :string - t.column "id", :integer, :limit => 20, :null => false + t.column "id", :bigint_pk, :null => false end - add_primary_key "gpx_file_tags", ["id"], :name => "gpx_file_tags_id_idx", :unique => true 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" - create_table "gpx_files", myisam_table do |t| - t.column "id", :bigint, :limit => 64, :null => false + t.column "id", :bigint_pk_64, :null => false t.column "user_id", :bigint, :limit => 20 t.column "visible", :boolean, :default => true, :null => false t.column "name", :string, :default => "", :null => false @@ -129,12 +112,9 @@ class CreateOsmDb < ActiveRecord::Migration t.column "inserted", :boolean end - add_primary_key "gpx_files", ["id"], :name => "gpx_files_id_idx", :unique => true add_index "gpx_files", ["timestamp"], :name => "gpx_files_timestamp_idx" add_index "gpx_files", ["visible", "public"], :name => "gpx_files_visible_public_idx" - change_column "gpx_files", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT" - create_table "gpx_pending_files", myisam_table do |t| t.column "originalname", :string t.column "tmpname", :string @@ -142,7 +122,7 @@ class CreateOsmDb < ActiveRecord::Migration end create_table "messages", myisam_table do |t| - t.column "id", :bigint, :limit => 20, :null => false + t.column "id", :bigint_pk, :null => false t.column "user_id", :bigint, :limit => 20, :null => false t.column "from_user_id", :bigint, :limit => 20, :null => false t.column "from_display_name", :string, :default => "" @@ -153,21 +133,14 @@ 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_index "messages", ["from_display_name"], :name => "from_name_idx" - change_column "messages", "id", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT" - create_table "meta_areas", myisam_table do |t| - t.column "id", :bigint, :limit => 64, :null => false + t.column "id", :bigint_pk_64, :null => false t.column "user_id", :bigint, :limit => 20 t.column "timestamp", :datetime end - add_primary_key "meta_areas", ["id"], :name => "meta_areas_id_idx", :unique => true - - change_column "meta_areas", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT" - create_table "nodes", myisam_table do |t| t.column "id", :bigint, :limit => 64 t.column "latitude", :double @@ -197,7 +170,7 @@ class CreateOsmDb < ActiveRecord::Migration create_table "users", innodb_table do |t| t.column "email", :string - t.column "id", :bigint, :limit => 20, :null => false + t.column "id", :bigint_pk, :null => false t.column "token", :string t.column "active", :integer, :default => 0, :null => false t.column "pass_crypt", :string @@ -214,12 +187,9 @@ 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_index "users", ["email"], :name => "users_email_idx" add_index "users", ["display_name"], :name => "users_display_name_idx" - change_column "users", "id", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT" - create_table "way_segments", myisam_table do |t| t.column "id", :bigint, :limit => 64, :default => 0, :null => false t.column "segment_id", :integer @@ -227,9 +197,9 @@ 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" + change_column "way_segments", "sequence_id", :bigint_auto_11 create_table "way_tags", myisam_table do |t| t.column "id", :bigint, :limit => 64, :default => 0, :null => false @@ -248,10 +218,10 @@ 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" + change_column "ways", "version", :bigint_auto_20 end def self.down