]> git.openstreetmap.org Git - rails.git/commitdiff
Cleanup migrations
authorTom Hughes <tom@compton.nu>
Sat, 10 Jan 2015 11:45:39 +0000 (11:45 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 11 Jan 2015 12:53:01 +0000 (12:53 +0000)
Cleanup our migrations, replacing as much of our custom code
and monkey patching with modern standard rails methods.

36 files changed:
db/migrate/001_create_osm_db.rb
db/migrate/002_cleanup_osm_db.rb
db/migrate/003_sql_session_store_setup.rb
db/migrate/004_user_enhancements.rb
db/migrate/005_tile_tracepoints.rb
db/migrate/006_tile_nodes.rb
db/migrate/007_add_relations.rb
db/migrate/008_remove_segments.rb
db/migrate/010_diary_comments.rb
db/migrate/018_create_acls.rb
db/migrate/020_populate_node_tags_and_remove.rb
db/migrate/021_move_to_innodb.rb
db/migrate/022_key_constraints.rb
db/migrate/023_add_changesets.rb
db/migrate/025_add_end_time_to_changesets.rb
db/migrate/028_add_more_changeset_indexes.rb
db/migrate/029_add_user_foreign_keys.rb
db/migrate/030_add_foreign_keys.rb
db/migrate/031_create_countries.rb
db/migrate/034_create_languages.rb
db/migrate/035_change_user_locale.rb
db/migrate/042_add_foreign_keys_to_oauth_tables.rb
db/migrate/044_create_user_roles.rb
db/migrate/045_create_user_blocks.rb
db/migrate/046_alter_user_roles_and_blocks.rb
db/migrate/054_refactor_map_bug_tables.rb
db/migrate/20110521142405_rename_bugs_to_notes.rb
db/migrate/20111212183945_add_lowercase_user_indexes.rb
db/migrate/20120318201948_create_redactions.rb
db/migrate/20120328090602_drop_session_table.rb
db/migrate/20120404205604_add_user_and_description_to_redaction.rb
db/migrate/20140115192822_add_text_index_to_note_comments.rb
db/migrate/20140507110937_create_changeset_comments.rb
db/migrate/20140519141742_add_join_table_between_users_and_changesets.rb
db/structure.sql
lib/migrate.rb

index d952c0a07693b60cf1297ff987d4a60c9c996874..34b0203408016ccc39091c611f725baad7d80be4 100644 (file)
@@ -2,13 +2,13 @@ require 'migrate'
 
 class CreateOsmDb < ActiveRecord::Migration
   def self.up
 
 class CreateOsmDb < ActiveRecord::Migration
   def self.up
-    create_table "current_nodes", innodb_table do |t|
-      t.column "id",        :bigint,   :limit => 64,                 :null => false
-      t.column "latitude",  :double
-      t.column "longitude", :double
-      t.column "user_id",   :bigint,   :limit => 20
+    create_table "current_nodes", :id => false do |t|
+      t.column "id",        :bigint, :null => false
+      t.column "latitude",  :float, :limit => 53
+      t.column "longitude", :float, :limit => 53
+      t.column "user_id",   :bigint
       t.column "visible",   :boolean
       t.column "visible",   :boolean
-      t.column "tags",      :text,                   :default => "", :null => false
+      t.column "tags",      :text, :default => "", :null => false
       t.column "timestamp", :datetime
     end
 
       t.column "timestamp", :datetime
     end
 
@@ -16,15 +16,13 @@ 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"
 
     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_auto_64
-
-    create_table "current_segments", innodb_table do |t|
-      t.column "id",        :bigint,   :limit => 64,                 :null => false
-      t.column "node_a",    :bigint,   :limit => 64
-      t.column "node_b",    :bigint,   :limit => 64
-      t.column "user_id",   :bigint,   :limit => 20
+    create_table "current_segments", :id => false do |t|
+      t.column "id",        :bigint, :null => false
+      t.column "node_a",    :bigint
+      t.column "node_b",    :bigint
+      t.column "user_id",   :bigint
       t.column "visible",   :boolean
       t.column "visible",   :boolean
-      t.column "tags",      :text,                   :default => "", :null => false
+      t.column "tags",      :text, :default => "", :null => false
       t.column "timestamp", :datetime
     end
 
       t.column "timestamp", :datetime
     end
 
@@ -32,51 +30,49 @@ 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"
 
     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_auto_64
-
-    create_table "current_way_segments", innodb_table do |t|
-      t.column "id",          :bigint, :limit => 64
-      t.column "segment_id",  :bigint, :limit => 11
-      t.column "sequence_id", :bigint, :limit => 11
+    create_table "current_way_segments", :id => false do |t|
+      t.column "id",          :bigint
+      t.column "segment_id",  :bigint
+      t.column "sequence_id", :bigint
     end
 
     add_index "current_way_segments", ["segment_id"], :name => "current_way_segments_seg_idx"
     add_index "current_way_segments", ["id"], :name => "current_way_segments_id_idx"
 
     end
 
     add_index "current_way_segments", ["segment_id"], :name => "current_way_segments_seg_idx"
     add_index "current_way_segments", ["id"], :name => "current_way_segments_id_idx"
 
-    create_table "current_way_tags", myisam_table do |t|
-      t.column "id", :bigint, :limit => 64
-      t.column "k",  :string,                :default => "", :null => false
-      t.column "v",  :string,                :default => "", :null => false
+    create_table "current_way_tags", :id => false do |t|
+      t.column "id", :bigint
+      t.column "k",  :string, :default => "", :null => false
+      t.column "v",  :string, :default => "", :null => false
     end
 
     add_index "current_way_tags", ["id"], :name => "current_way_tags_id_idx"
     end
 
     add_index "current_way_tags", ["id"], :name => "current_way_tags_id_idx"
-    add_fulltext_index "current_way_tags", "v"
+    add_index "current_way_tags", "v", :name => "current_way_tags_v_idx"
 
 
-    create_table "current_ways", myisam_table do |t|
-      t.column "id",        :bigint_pk_64, :null => false
-      t.column "user_id",   :bigint,   :limit => 20
+    create_table "current_ways", :id => false do |t|
+      t.column "id",        :bigserial, :primary_key => true, :null => false
+      t.column "user_id",   :bigint
       t.column "timestamp", :datetime
       t.column "visible",   :boolean
     end
 
       t.column "timestamp", :datetime
       t.column "visible",   :boolean
     end
 
-    create_table "diary_entries", myisam_table do |t|
-      t.column "id",         :bigint_pk, :null => false
-      t.column "user_id",    :bigint,   :limit => 20, :null => false
+    create_table "diary_entries", :id => false do |t|
+      t.column "id",         :bigserial, :primary_key => true, :null => false
+      t.column "user_id",    :bigint, :null => false
       t.column "title",      :string
       t.column "body",       :text
       t.column "created_at", :datetime
       t.column "updated_at", :datetime
     end
 
       t.column "title",      :string
       t.column "body",       :text
       t.column "created_at", :datetime
       t.column "updated_at", :datetime
     end
 
-    create_table "friends", myisam_table do |t|
-      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
+    create_table "friends", :id => false do |t|
+      t.column "id",             :bigserial, :primary_key => true, :null => false
+      t.column "user_id",        :bigint, :null => false
+      t.column "friend_user_id", :bigint, :null => false
     end
 
     add_index "friends", ["friend_user_id"], :name => "user_id_idx"
 
     end
 
     add_index "friends", ["friend_user_id"], :name => "user_id_idx"
 
-    create_table "gps_points", myisam_table do |t|
+    create_table "gps_points", :id => false do |t|
       t.column "altitude",  :float
       t.column "user_id",   :integer
       t.column "trackid",   :integer
       t.column "altitude",  :float
       t.column "user_id",   :integer
       t.column "trackid",   :integer
@@ -90,77 +86,77 @@ class CreateOsmDb < ActiveRecord::Migration
     add_index "gps_points", ["user_id"], :name => "points_uid_idx"
     add_index "gps_points", ["gpx_id"], :name => "points_gpxid_idx"
 
     add_index "gps_points", ["user_id"], :name => "points_uid_idx"
     add_index "gps_points", ["gpx_id"], :name => "points_gpxid_idx"
 
-    create_table "gpx_file_tags", myisam_table do |t|
-      t.column "gpx_id", :bigint,  :limit => 64, :default => 0, :null => false
+    create_table "gpx_file_tags", :id => false do |t|
+      t.column "gpx_id", :bigint, :default => 0, :null => false
       t.column "tag",    :string
       t.column "tag",    :string
-      t.column "id",     :bigint_pk, :null => false
+      t.column "id",     :bigserial, :primary_key => true, :null => false
     end
 
     add_index "gpx_file_tags", ["gpx_id"], :name => "gpx_file_tags_gpxid_idx"
 
     end
 
     add_index "gpx_file_tags", ["gpx_id"], :name => "gpx_file_tags_gpxid_idx"
 
-    create_table "gpx_files", myisam_table do |t|
-      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
-      t.column "size",        :bigint,   :limit => 20
-      t.column "latitude",    :double
-      t.column "longitude",   :double
+    create_table "gpx_files", :id => false do |t|
+      t.column "id",          :bigserial, :primary_key => true, :null => false
+      t.column "user_id",     :bigint
+      t.column "visible",     :boolean, :default => true, :null => false
+      t.column "name",        :string, :default => "", :null => false
+      t.column "size",        :bigint
+      t.column "latitude",    :float, :limit => 53
+      t.column "longitude",   :float, :limit => 53
       t.column "timestamp",   :datetime
       t.column "timestamp",   :datetime
-      t.column "public",      :boolean,                :default => true, :null => false
-      t.column "description", :string,                 :default => ""
+      t.column "public",      :boolean, :default => true, :null => false
+      t.column "description", :string, :default => ""
       t.column "inserted",    :boolean
     end
 
     add_index "gpx_files", ["timestamp"], :name => "gpx_files_timestamp_idx"
     add_index "gpx_files", ["visible", "public"], :name => "gpx_files_visible_public_idx"
 
       t.column "inserted",    :boolean
     end
 
     add_index "gpx_files", ["timestamp"], :name => "gpx_files_timestamp_idx"
     add_index "gpx_files", ["visible", "public"], :name => "gpx_files_visible_public_idx"
 
-    create_table "gpx_pending_files", myisam_table do |t|
+    create_table "gpx_pending_files", :id => false do |t|
       t.column "originalname", :string
       t.column "tmpname",      :string
       t.column "originalname", :string
       t.column "tmpname",      :string
-      t.column "user_id",      :bigint,  :limit => 20
+      t.column "user_id",      :bigint
     end
 
     end
 
-    create_table "messages", myisam_table do |t|
-      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 => ""
+    create_table "messages", :id => false do |t|
+      t.column "id",                :bigserial, :primary_key => true, :null => false
+      t.column "user_id",           :bigint, :null => false
+      t.column "from_user_id",      :bigint, :null => false
+      t.column "from_display_name", :string, :default => ""
       t.column "title",             :string
       t.column "body",              :text
       t.column "sent_on",           :datetime
       t.column "title",             :string
       t.column "body",              :text
       t.column "sent_on",           :datetime
-      t.column "message_read",      :boolean,                :default => false
-      t.column "to_user_id",        :bigint,   :limit => 20,                    :null => false
+      t.column "message_read",      :boolean, :default => false
+      t.column "to_user_id",        :bigint, :null => false
     end
 
     add_index "messages", ["from_display_name"], :name => "from_name_idx"
 
     end
 
     add_index "messages", ["from_display_name"], :name => "from_name_idx"
 
-    create_table "meta_areas", myisam_table do |t|
-      t.column "id",        :bigint_pk_64, :null => false
-      t.column "user_id",   :bigint,  :limit => 20
+    create_table "meta_areas", :id => false do |t|
+      t.column "id",        :bigserial, :primary_key => true, :null => false
+      t.column "user_id",   :bigint
       t.column "timestamp", :datetime
     end
 
       t.column "timestamp", :datetime
     end
 
-    create_table "nodes", myisam_table do |t|
-      t.column "id",        :bigint,  :limit => 64
-      t.column "latitude",  :double
-      t.column "longitude", :double
-      t.column "user_id",   :bigint,  :limit => 20
+    create_table "nodes", :id => false do |t|
+      t.column "id",        :bigint
+      t.column "latitude",  :float, :limit => 53
+      t.column "longitude", :float, :limit => 53
+      t.column "user_id",   :bigint
       t.column "visible",   :boolean
       t.column "visible",   :boolean
-      t.column "tags",      :text,                  :default => "", :null => false
+      t.column "tags",      :text, :default => "", :null => false
       t.column "timestamp", :datetime
     end
 
     add_index "nodes", ["id"], :name => "nodes_uid_idx"
     add_index "nodes", ["latitude", "longitude"], :name => "nodes_latlon_idx"
 
       t.column "timestamp", :datetime
     end
 
     add_index "nodes", ["id"], :name => "nodes_uid_idx"
     add_index "nodes", ["latitude", "longitude"], :name => "nodes_latlon_idx"
 
-    create_table "segments", myisam_table do |t|
-      t.column "id",        :bigint,  :limit => 64
-      t.column "node_a",    :bigint,  :limit => 64
-      t.column "node_b",    :bigint,  :limit => 64
-      t.column "user_id",   :bigint,  :limit => 20
+    create_table "segments", :id => false do |t|
+      t.column "id",        :bigint
+      t.column "node_a",    :bigint
+      t.column "node_b",    :bigint
+      t.column "user_id",   :bigint
       t.column "visible",   :boolean
       t.column "visible",   :boolean
-      t.column "tags",      :text,                  :default => "", :null => false
+      t.column "tags",      :text, :default => "", :null => false
       t.column "timestamp", :datetime
     end
 
       t.column "timestamp", :datetime
     end
 
@@ -168,60 +164,56 @@ class CreateOsmDb < ActiveRecord::Migration
     add_index "segments", ["node_b"], :name => "street_segments_nodeb_idx"
     add_index "segments", ["id"], :name => "street_segment_uid_idx"
 
     add_index "segments", ["node_b"], :name => "street_segments_nodeb_idx"
     add_index "segments", ["id"], :name => "street_segment_uid_idx"
 
-    create_table "users", innodb_table do |t|
+    create_table "users", :id => false do |t|
       t.column "email",         :string
       t.column "email",         :string
-      t.column "id",            :bigint_pk,                    :null => false
+      t.column "id",            :bigserial, :primary_key => true, :null => false
       t.column "token",         :string
       t.column "token",         :string
-      t.column "active",        :integer,                :default => 0,     :null => false
+      t.column "active",        :integer, :default => 0, :null => false
       t.column "pass_crypt",    :string
       t.column "creation_time", :datetime
       t.column "timeout",       :datetime
       t.column "pass_crypt",    :string
       t.column "creation_time", :datetime
       t.column "timeout",       :datetime
-      t.column "display_name",  :string,                 :default => ""
+      t.column "display_name",  :string, :default => ""
       t.column "preferences",   :text
       t.column "preferences",   :text
-      t.column "data_public",   :boolean,                :default => false
-      t.column "description",   :text,                   :default => "",    :null => false
-      t.column "home_lat",      :double,                 :default => 1
-      t.column "home_lon",      :double,                 :default => 1
-      t.column "within_lon",    :double
-      t.column "within_lat",    :double
-      t.column "home_zoom",     :integer,  :limit => 2,  :default => 3
+      t.column "data_public",   :boolean, :default => false
+      t.column "description",   :text, :default => "", :null => false
+      t.column "home_lat",      :float, :limit => 53, :default => 1
+      t.column "home_lon",      :float, :limit => 53, :default => 1
+      t.column "within_lon",    :float, :limit => 53
+      t.column "within_lat",    :float, :limit => 53
+      t.column "home_zoom",     :integer, :limit => 2, :default => 3
     end
 
     add_index "users", ["email"], :name => "users_email_idx"
     add_index "users", ["display_name"], :name => "users_display_name_idx"
 
     end
 
     add_index "users", ["email"], :name => "users_email_idx"
     add_index "users", ["display_name"], :name => "users_display_name_idx"
 
-    create_table "way_segments", myisam_table do |t|
-      t.column "id",          :bigint,  :limit => 64, :default => 0, :null => false
+    create_table "way_segments", :id => false do |t|
+      t.column "id",          :bigint, :default => 0, :null => false
       t.column "segment_id",  :integer
       t.column "segment_id",  :integer
-      t.column "version",     :bigint,  :limit => 20, :default => 0, :null => false
-      t.column "sequence_id", :bigint,  :limit => 11,                :null => false
+      t.column "version",     :bigint, :default => 0, :null => false
+      t.column "sequence_id", :bigint, :null => false
     end
 
     add_primary_key "way_segments", ["id", "version", "sequence_id"]
 
     end
 
     add_primary_key "way_segments", ["id", "version", "sequence_id"]
 
-    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
+    create_table "way_tags", :id => false do |t|
+      t.column "id",      :bigint, :default => 0, :null => false
       t.column "k",       :string
       t.column "v",       :string
       t.column "k",       :string
       t.column "v",       :string
-      t.column "version", :bigint,  :limit => 20
+      t.column "version", :bigint
     end
 
     add_index "way_tags", ["id", "version"], :name => "way_tags_id_version_idx"
 
     end
 
     add_index "way_tags", ["id", "version"], :name => "way_tags_id_version_idx"
 
-    create_table "ways", myisam_table do |t|
-      t.column "id",        :bigint,   :limit => 64, :default => 0, :null => false
-      t.column "user_id",   :bigint,   :limit => 20
+    create_table "ways", :id => false do |t|
+      t.column "id",        :bigint, :default => 0, :null => false
+      t.column "user_id",   :bigint
       t.column "timestamp", :datetime
       t.column "timestamp", :datetime
-      t.column "version",   :bigint,   :limit => 20,                   :null => false
-      t.column "visible",   :boolean,                :default => true
+      t.column "version",   :bigint, :null => false
+      t.column "visible",   :boolean, :default => true
     end
 
     add_primary_key "ways", ["id", "version"]
     add_index "ways", ["id"], :name => "ways_id_version_idx"
     end
 
     add_primary_key "ways", ["id", "version"]
     add_index "ways", ["id"], :name => "ways_id_version_idx"
-
-    change_column "ways", "version", :bigint_auto_20
   end
 
   def self.down
   end
 
   def self.down
index 630661a0be01c8ea872678d6b830f761b5307178..fb27c91b7bcc8078e1b01245ef5198066642e330 100644 (file)
@@ -2,34 +2,33 @@ require 'migrate'
 
 class CleanupOsmDb < ActiveRecord::Migration
   def self.up
 
 class CleanupOsmDb < ActiveRecord::Migration
   def self.up
-    change_column "current_nodes", "latitude", :double, :null => false
-    change_column "current_nodes", "longitude", :double, :null => false
-    change_column "current_nodes", "user_id", :bigint, :limit => 20, :null => false
+    change_column "current_nodes", "latitude", :float, :limit => 53, :null => false
+    change_column "current_nodes", "longitude", :float, :limit => 53, :null => false
+    change_column "current_nodes", "user_id", :bigint, :null => false
     change_column "current_nodes", "visible", :boolean, :null => false
     change_column "current_nodes", "timestamp", :datetime, :null => false
     add_primary_key "current_nodes", ["id"]
     remove_index "current_nodes", :name => "current_nodes_id_idx"
 
     change_column "current_nodes", "visible", :boolean, :null => false
     change_column "current_nodes", "timestamp", :datetime, :null => false
     add_primary_key "current_nodes", ["id"]
     remove_index "current_nodes", :name => "current_nodes_id_idx"
 
-    change_column "current_segments", "node_a", :bigint, :limit => 64, :null => false
-    change_column "current_segments", "node_b", :bigint, :limit => 64, :null => false
-    change_column "current_segments", "user_id", :bigint, :limit => 20, :null => false
+    change_column "current_segments", "node_a", :bigint, :null => false
+    change_column "current_segments", "node_b", :bigint, :null => false
+    change_column "current_segments", "user_id", :bigint, :null => false
     change_column "current_segments", "visible", :boolean, :null => false
     change_column "current_segments", "timestamp", :datetime, :null => false
     add_primary_key "current_segments", ["id"]
     remove_index "current_segments", :name => "current_segments_id_visible_idx"
 
     change_column "current_segments", "visible", :boolean, :null => false
     change_column "current_segments", "timestamp", :datetime, :null => false
     add_primary_key "current_segments", ["id"]
     remove_index "current_segments", :name => "current_segments_id_visible_idx"
 
-    change_column "current_way_segments", "id", :bigint, :limit => 64, :null => false
-    change_column "current_way_segments", "segment_id", :bigint, :limit => 64, :null => false
-    change_column "current_way_segments", "sequence_id", :bigint, :limit => 11, :null => false
+    change_column "current_way_segments", "id", :bigint, :null => false
+    change_column "current_way_segments", "segment_id", :bigint, :null => false
+    change_column "current_way_segments", "sequence_id", :bigint, :null => false
     add_primary_key "current_way_segments", ["id", "sequence_id"]
     remove_index "current_way_segments", :name => "current_way_segments_id_idx"
 
     add_primary_key "current_way_segments", ["id", "sequence_id"]
     remove_index "current_way_segments", :name => "current_way_segments_id_idx"
 
-    change_column "current_way_tags", "id", :bigint, :limit => 64, :null => false
+    change_column "current_way_tags", "id", :bigint, :null => false
 
 
-    change_column "current_ways", "user_id", :bigint, :limit => 20, :null => false
+    change_column "current_ways", "user_id", :bigint, :null => false
     change_column "current_ways", "timestamp", :datetime, :null => false
     change_column "current_ways", "visible", :boolean, :null => false
     change_column "current_ways", "timestamp", :datetime, :null => false
     change_column "current_ways", "visible", :boolean, :null => false
-    change_engine "current_ways", "InnoDB"
 
     change_column "diary_entries", "title", :string, :null => false
     change_column "diary_entries", "body", :text, :null => false
 
     change_column "diary_entries", "title", :string, :null => false
     change_column "diary_entries", "body", :text, :null => false
@@ -45,11 +44,11 @@ class CleanupOsmDb < ActiveRecord::Migration
     change_column "gps_points", "trackid", :integer, :null => false
     change_column "gps_points", "latitude", :integer, :null => false
     change_column "gps_points", "longitude", :integer, :null => false
     change_column "gps_points", "trackid", :integer, :null => false
     change_column "gps_points", "latitude", :integer, :null => false
     change_column "gps_points", "longitude", :integer, :null => false
-    change_column "gps_points", "gpx_id", :bigint, :limit => 64, :null => false
+    change_column "gps_points", "gpx_id", :bigint, :null => false
 
     change_column "gpx_file_tags", "tag", :string, :null => false
 
 
     change_column "gpx_file_tags", "tag", :string, :null => false
 
-    change_column "gpx_files", "user_id", :bigint,   :limit => 20, :null => false
+    change_column "gpx_files", "user_id", :bigint, :null => false
     change_column "gpx_files", "timestamp", :datetime, :null => false
     change_column "gpx_files", "description", :string, :default => "", :null => false
     change_column "gpx_files", "inserted", :boolean, :null => false
     change_column "gpx_files", "timestamp", :datetime, :null => false
     change_column "gpx_files", "description", :string, :default => "", :null => false
     change_column "gpx_files", "inserted", :boolean, :null => false
@@ -67,18 +66,18 @@ class CleanupOsmDb < ActiveRecord::Migration
 
     drop_table "meta_areas"
 
 
     drop_table "meta_areas"
 
-    change_column "nodes", "id", :bigint, :limit => 64, :null => false
-    change_column "nodes", "latitude", :double, :null => false
-    change_column "nodes", "longitude", :double, :null => false
-    change_column "nodes", "user_id", :bigint, :limit => 20, :null => false
+    change_column "nodes", "id", :bigint, :null => false
+    change_column "nodes", "latitude", :float, :limit => 53, :null => false
+    change_column "nodes", "longitude", :float, :limit => 53, :null => false
+    change_column "nodes", "user_id", :bigint, :null => false
     change_column "nodes", "visible", :boolean, :null => false
     change_column "nodes", "timestamp", :datetime, :null => false
     add_index "nodes", ["timestamp"], :name => "nodes_timestamp_idx"
 
     change_column "nodes", "visible", :boolean, :null => false
     change_column "nodes", "timestamp", :datetime, :null => false
     add_index "nodes", ["timestamp"], :name => "nodes_timestamp_idx"
 
-    change_column "segments", "id", :bigint, :limit => 64, :null => false
-    change_column "segments", "node_a", :bigint, :limit => 64, :null => false
-    change_column "segments", "node_b", :bigint, :limit => 64, :null => false
-    change_column "segments", "user_id", :bigint, :limit => 20, :null => false
+    change_column "segments", "id", :bigint, :null => false
+    change_column "segments", "node_a", :bigint, :null => false
+    change_column "segments", "node_b", :bigint, :null => false
+    change_column "segments", "user_id", :bigint, :null => false
     change_column "segments", "visible", :boolean, :null => false
     change_column "segments", "timestamp", :datetime, :null => false
     add_index "segments", ["timestamp"], :name => "segments_timestamp_idx"
     change_column "segments", "visible", :boolean, :null => false
     change_column "segments", "timestamp", :datetime, :null => false
     add_index "segments", ["timestamp"], :name => "segments_timestamp_idx"
@@ -89,20 +88,20 @@ class CleanupOsmDb < ActiveRecord::Migration
     change_column "users", "creation_time", :datetime, :null => false
     change_column "users", "display_name", :string, :default => "", :null => false
     change_column "users", "data_public", :boolean, :default => false, :null => false
     change_column "users", "creation_time", :datetime, :null => false
     change_column "users", "display_name", :string, :default => "", :null => false
     change_column "users", "data_public", :boolean, :default => false, :null => false
-    change_column "users", "home_lat", :double, :default => nil
-    change_column "users", "home_lon", :double, :default => nil
+    change_column "users", "home_lat", :float, :limit => 53, :default => nil
+    change_column "users", "home_lon", :float, :limit => 53, :default => nil
     remove_index "users", :name => "users_email_idx"
     add_index "users", ["email"], :name => "users_email_idx", :unique => true
     remove_index "users", :name => "users_display_name_idx"
     add_index "users", ["display_name"], :name => "users_display_name_idx", :unique => true
 
     remove_index "users", :name => "users_email_idx"
     add_index "users", ["email"], :name => "users_email_idx", :unique => true
     remove_index "users", :name => "users_display_name_idx"
     add_index "users", ["display_name"], :name => "users_display_name_idx", :unique => true
 
-    change_column "way_segments", "segment_id", :bigint, :limit => 64, :null => false
+    change_column "way_segments", "segment_id", :bigint, :null => false
  
     change_column "way_tags", "k", :string, :null => false
     change_column "way_tags", "v", :string, :null => false
  
     change_column "way_tags", "k", :string, :null => false
     change_column "way_tags", "v", :string, :null => false
-    change_column "way_tags", "version", :bigint, :limit => 20, :null => false
+    change_column "way_tags", "version", :bigint, :null => false
 
 
-    change_column "ways", "user_id", :bigint, :limit => 20, :null => false
+    change_column "ways", "user_id", :bigint, :null => false
     change_column "ways", "timestamp", :datetime, :null => false
     change_column "ways", "visible", :boolean, :default => true, :null => false
     remove_index "ways", :name => "ways_id_version_idx"
     change_column "ways", "timestamp", :datetime, :null => false
     change_column "ways", "visible", :boolean, :default => true, :null => false
     remove_index "ways", :name => "ways_id_version_idx"
@@ -114,9 +113,9 @@ class CleanupOsmDb < ActiveRecord::Migration
     add_index "ways", ["id"], :name => "ways_id_version_idx"
     change_column "ways", "visible", :boolean, :default => true
     change_column "ways", "timestamp", :datetime
     add_index "ways", ["id"], :name => "ways_id_version_idx"
     change_column "ways", "visible", :boolean, :default => true
     change_column "ways", "timestamp", :datetime
-    change_column "ways", "user_id", :bigint, :limit => 20
+    change_column "ways", "user_id", :bigint
 
 
-    change_column "way_tags", "version", :bigint, :limit => 20
+    change_column "way_tags", "version", :bigint
     change_column "way_tags", "v", :string, :default => nil
     change_column "way_tags", "k", :string, :default => nil
 
     change_column "way_tags", "v", :string, :default => nil
     change_column "way_tags", "k", :string, :default => nil
 
@@ -126,8 +125,8 @@ class CleanupOsmDb < ActiveRecord::Migration
     add_index "users", ["display_name"], :name => "users_display_name_idx"
     remove_index "users", :name => "users_email_idx"
     add_index "users", ["email"], :name => "users_email_idx"
     add_index "users", ["display_name"], :name => "users_display_name_idx"
     remove_index "users", :name => "users_email_idx"
     add_index "users", ["email"], :name => "users_email_idx"
-    change_column "users", "home_lon", :double, :default => 1
-    change_column "users", "home_lat", :double, :default => 1
+    change_column "users", "home_lon", :float, :limit => 53, :default => 1
+    change_column "users", "home_lat", :float, :limit => 53, :default => 1
     change_column "users", "data_public", :boolean, :default => false
     change_column "users", "display_name", :string, :default => ""
     change_column "users", "creation_time", :datetime
     change_column "users", "data_public", :boolean, :default => false
     change_column "users", "display_name", :string, :default => ""
     change_column "users", "creation_time", :datetime
@@ -138,22 +137,22 @@ class CleanupOsmDb < ActiveRecord::Migration
     remove_index "segments", :name => "segments_timestamp_idx"
     change_column "segments", "timestamp", :datetime
     change_column "segments", "visible", :boolean
     remove_index "segments", :name => "segments_timestamp_idx"
     change_column "segments", "timestamp", :datetime
     change_column "segments", "visible", :boolean
-    change_column "segments", "user_id", :bigint, :limit => 20
-    change_column "segments", "node_b", :bigint, :limit => 64
-    change_column "segments", "node_a", :bigint, :limit => 64
-    change_column "segments", "id", :bigint, :limit => 64
+    change_column "segments", "user_id", :bigint
+    change_column "segments", "node_b", :bigint
+    change_column "segments", "node_a", :bigint
+    change_column "segments", "id", :bigint
 
     remove_index "nodes", :name => "nodes_timestamp_idx"
     change_column "nodes", "timestamp", :datetime
     change_column "nodes", "visible", :boolean
 
     remove_index "nodes", :name => "nodes_timestamp_idx"
     change_column "nodes", "timestamp", :datetime
     change_column "nodes", "visible", :boolean
-    change_column "nodes", "user_id", :bigint, :limit => 20
-    change_column "nodes", "longitude", :double
-    change_column "nodes", "latitude", :double
-    change_column "nodes", "id", :bigint, :limit => 64
-
-    create_table "meta_areas", myisam_table do |t|
-      t.column "id",        :bigint_pk_64, :null => false
-      t.column "user_id",   :bigint,  :limit => 20
+    change_column "nodes", "user_id", :bigint
+    change_column "nodes", "longitude", :float, :limit => 53
+    change_column "nodes", "latitude", :float, :limit => 53
+    change_column "nodes", "id", :bigint
+
+    create_table "meta_areas", :id => false do |t|
+      t.column "id", :bigserial, :primary_key => true, :null => false
+      t.column "user_id", :bigint
       t.column "timestamp", :datetime
     end
 
       t.column "timestamp", :datetime
     end
 
@@ -163,27 +162,27 @@ class CleanupOsmDb < ActiveRecord::Migration
     change_column "messages", "body", :text
     change_column "messages", "title", :string, :default => nil
     add_column "messages", "from_display_name", :string, :default => ""
     change_column "messages", "body", :text
     change_column "messages", "title", :string, :default => nil
     add_column "messages", "from_display_name", :string, :default => ""
-    add_column "messages", "user_id", :bigint, :limit => 20, :null => false
+    add_column "messages", "user_id", :bigint, :null => false
     add_index "messages", ["from_display_name"], :name => "from_name_idx"
 
     add_index "messages", ["from_display_name"], :name => "from_name_idx"
 
-    create_table "gpx_pending_files", myisam_table do |t|
+    create_table "gpx_pending_files", :id => false do |t|
       t.column "originalname", :string
       t.column "originalname", :string
-      t.column "tmpname",      :string
-      t.column "user_id",      :bigint,  :limit => 20
+      t.column "tmpname", :string
+      t.column "user_id", :bigint
     end
 
     change_column "gpx_files", "inserted", :boolean
     change_column "gpx_files", "description", :string, :default => ""
     change_column "gpx_files", "timestamp", :datetime
     end
 
     change_column "gpx_files", "inserted", :boolean
     change_column "gpx_files", "description", :string, :default => ""
     change_column "gpx_files", "timestamp", :datetime
-    change_column "gpx_files", "user_id", :bigint,   :limit => 20
+    change_column "gpx_files", "user_id", :bigint
 
     change_column "gpx_file_tags", "tag", :string, :default => nil
 
 
     change_column "gpx_file_tags", "tag", :string, :default => nil
 
-    change_column "gps_points", "gpx_id", :integer, :limit => 20
+    change_column "gps_points", "gpx_id", :integer
     change_column "gps_points", "longitude", :integer
     change_column "gps_points", "latitude", :integer
     change_column "gps_points", "trackid", :integer
     change_column "gps_points", "longitude", :integer
     change_column "gps_points", "latitude", :integer
     change_column "gps_points", "trackid", :integer
-    add_column "gps_points", "user_id", :integer, :limit => 20
+    add_column "gps_points", "user_id", :integer
     add_index "gps_points", ["user_id"], :name => "points_uid_idx"
 
     remove_index "friends", :name => "friends_user_id_idx"
     add_index "gps_points", ["user_id"], :name => "points_uid_idx"
 
     remove_index "friends", :name => "friends_user_id_idx"
@@ -193,34 +192,32 @@ class CleanupOsmDb < ActiveRecord::Migration
     change_column "diary_entries", "body", :text
     change_column "diary_entries", "title", :string, :default => nil
 
     change_column "diary_entries", "body", :text
     change_column "diary_entries", "title", :string, :default => nil
 
-    change_engine "current_ways", "MyISAM"
     change_column "current_ways", "visible", :boolean
     change_column "current_ways", "timestamp", :datetime
     change_column "current_ways", "visible", :boolean
     change_column "current_ways", "timestamp", :datetime
-    change_column "current_ways", "user_id", :bigint, :limit => 20
+    change_column "current_ways", "user_id", :bigint
 
 
-    change_column "current_way_tags", "id", :bigint, :limit => 64
+    change_column "current_way_tags", "id", :bigint
 
     add_index "current_way_segments", ["id"], :name => "current_way_segments_id_idx"
     remove_primary_key "current_way_segments"
 
     add_index "current_way_segments", ["id"], :name => "current_way_segments_id_idx"
     remove_primary_key "current_way_segments"
-    change_column "current_way_segments", "sequence_id", :bigint, :limit => 11
-    change_column "current_way_segments", "segment_id", :bigint, :limit => 11
-    change_column "current_way_segments", "id", :bigint, :limit => 64
+    change_column "current_way_segments", "sequence_id", :bigint
+    change_column "current_way_segments", "segment_id", :bigint
+    change_column "current_way_segments", "id", :bigint
 
     add_index "current_segments", ["id", "visible"], :name => "current_segments_id_visible_idx"
     remove_primary_key "current_segments"
     change_column "current_segments", "timestamp", :datetime
     change_column "current_segments", "visible", :boolean
 
     add_index "current_segments", ["id", "visible"], :name => "current_segments_id_visible_idx"
     remove_primary_key "current_segments"
     change_column "current_segments", "timestamp", :datetime
     change_column "current_segments", "visible", :boolean
-    change_column "current_segments", "user_id", :bigint, :limit => 20
-    change_column "current_segments", "node_b", :bigint, :limit => 64
-    change_column "current_segments", "node_a", :bigint, :limit => 64
+    change_column "current_segments", "user_id", :bigint
+    change_column "current_segments", "node_b", :bigint
+    change_column "current_segments", "node_a", :bigint
     
     add_index "current_nodes", ["id"], :name => "current_nodes_id_idx"
     remove_primary_key "current_nodes"
     change_column "current_nodes", "timestamp", :datetime
     change_column "current_nodes", "visible", :boolean
     
     add_index "current_nodes", ["id"], :name => "current_nodes_id_idx"
     remove_primary_key "current_nodes"
     change_column "current_nodes", "timestamp", :datetime
     change_column "current_nodes", "visible", :boolean
-    change_column "current_nodes", "user_id", :bigint, :limit => 20
-    change_column "current_nodes", "longitude", :double
-    change_column "current_nodes", "latitude", :double
-    change_column "current_nodes", "id", :bigint_auto_64
+    change_column "current_nodes", "user_id", :bigint
+    change_column "current_nodes", "longitude", :float, :limit => 53
+    change_column "current_nodes", "latitude", :float, :limit => 53
   end
 end
   end
 end
index 5853d4d000a65e3f8cc9e7f6c101f4013559d9a9..69ad969b7432a435dd721b276f5a23509b1f8cda 100644 (file)
@@ -2,7 +2,7 @@ require 'migrate'
 
 class SqlSessionStoreSetup < ActiveRecord::Migration
   def self.up
 
 class SqlSessionStoreSetup < ActiveRecord::Migration
   def self.up
-    create_table "sessions", :options => innodb_option do |t|
+    create_table "sessions" do |t|
       t.column "session_id", :string
       t.column "data",       :text
       t.column "created_at", :timestamp
       t.column "session_id", :string
       t.column "data",       :text
       t.column "created_at", :timestamp
index af4b651238fde2c791f2e0471afcea4fb13b1cb6..8b352be3eed7eadd75feecd87b10ee7d76643760 100644 (file)
@@ -2,23 +2,23 @@ require 'migrate'
 
 class UserEnhancements < ActiveRecord::Migration
   def self.up
 
 class UserEnhancements < ActiveRecord::Migration
   def self.up
-    add_column "diary_entries", "latitude", :double
-    add_column "diary_entries", "longitude", :double
+    add_column "diary_entries", "latitude", :float, :limit => 53
+    add_column "diary_entries", "longitude", :float, :limit => 53
     add_column "diary_entries", "language", :string, :limit => 3
 
     add_column "diary_entries", "language", :string, :limit => 3
 
-    create_table "user_preferences", innodb_table do |t|
-      t.column "user_id", :bigint, :limit => 20, :null => false
-      t.column "k",       :string, :null => false
-      t.column "v",       :string, :null => false
+    create_table "user_preferences", :id => false do |t|
+      t.column "user_id", :bigint, :null => false
+      t.column "k", :string, :null => false
+      t.column "v", :string, :null => false
     end
 
     add_primary_key "user_preferences", ["user_id", "k"]
 
     end
 
     add_primary_key "user_preferences", ["user_id", "k"]
 
-    create_table "user_tokens", innodb_table do |t|
-      t.column "id",      :bigint_pk, :null => false
-      t.column "user_id", :bigint,   :limit => 20, :null => false
-      t.column "token",   :string,   :null => false
-      t.column "expiry",  :datetime, :null => false
+    create_table "user_tokens", :id => false do |t|
+      t.column "id", :bigserial, :primary_key => true, :null => false
+      t.column "user_id", :bigint, :null => false
+      t.column "token", :string, :null => false
+      t.column "expiry", :datetime, :null => false
     end
 
     add_index "user_tokens", ["token"], :name => "user_tokens_token_idx", :unique => true
     end
 
     add_index "user_tokens", ["token"], :name => "user_tokens_token_idx", :unique => true
@@ -41,8 +41,8 @@ class UserEnhancements < ActiveRecord::Migration
   def self.down
     remove_column "users", "pass_salt"
     remove_column "users", "nearby"
   def self.down
     remove_column "users", "pass_salt"
     remove_column "users", "nearby"
-    add_column "users", "within_lat", :double
-    add_column "users", "within_lon", :double
+    add_column "users", "within_lat", :float, :limit => 53
+    add_column "users", "within_lon", :float, :limit => 53
     add_column "users", "timeout", :datetime
     add_column "users", "token", :string
 
     add_column "users", "timeout", :datetime
     add_column "users", "token", :string
 
index d429b6fdc8fe36408cdb61d87adb4a159048ade1..fea6d41379ee909ae873923b7571da5346f39efb 100644 (file)
@@ -2,7 +2,7 @@ require 'migrate'
 
 class TileTracepoints < ActiveRecord::Migration
   def self.up
 
 class TileTracepoints < ActiveRecord::Migration
   def self.up
-    add_column "gps_points", "tile", :four_byte_unsigned
+    add_column "gps_points", "tile", :bigint
     add_index "gps_points", ["tile"], :name => "points_tile_idx"
     remove_index "gps_points", :name => "points_idx"
 
     add_index "gps_points", ["tile"], :name => "points_tile_idx"
     remove_index "gps_points", :name => "points_idx"
 
index 91f8acb6b1122cde583febf42ca03f1f70abc4df..8bfb6bc3fbca82765ddf2cfb7a63d44898505817 100644 (file)
@@ -39,21 +39,21 @@ class TileNodes < ActiveRecord::Migration
 
     rename_table "current_nodes", "current_nodes_v5"
 
 
     rename_table "current_nodes", "current_nodes_v5"
 
-    create_table "current_nodes", innodb_table do |t|
-      t.column "id",        :bigint_pk_64,                           :null => false
-      t.column "latitude",  :integer,                                :null => false
-      t.column "longitude", :integer,                                :null => false
-      t.column "user_id",   :bigint,   :limit => 20,                 :null => false
-      t.column "visible",   :boolean,                                :null => false
-      t.column "tags",      :text,                   :default => "", :null => false
-      t.column "timestamp", :datetime,                               :null => false
-      t.column "tile",      :integer,                                :null => false
+    create_table "current_nodes", :id => false do |t|
+      t.column "id",        :bigserial, :primary_key => true, :null => false
+      t.column "latitude",  :integer, :null => false
+      t.column "longitude", :integer, :null => false
+      t.column "user_id",   :bigint, :null => false
+      t.column "visible",   :boolean, :null => false
+      t.column "tags",      :text, :default => "", :null => false
+      t.column "timestamp", :datetime, :null => false
+      t.column "tile",      :integer, :null => false
     end
 
     add_index "current_nodes", ["timestamp"], :name => "current_nodes_timestamp_idx"
     add_index "current_nodes", ["tile"], :name => "current_nodes_tile_idx"
 
     end
 
     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", :four_byte_unsigned
+    change_column "current_nodes", "tile", :bigint
 
     upgrade_table "current_nodes_v5", "current_nodes", Node
     
 
     upgrade_table "current_nodes_v5", "current_nodes", Node
     
@@ -63,22 +63,22 @@ class TileNodes < ActiveRecord::Migration
     remove_index "nodes", :name=> "nodes_timestamp_idx"
     rename_table "nodes", "nodes_v5"
 
     remove_index "nodes", :name=> "nodes_timestamp_idx"
     rename_table "nodes", "nodes_v5"
 
-    create_table "nodes", myisam_table do |t|
-      t.column "id",        :bigint,   :limit => 64,                 :null => false
-      t.column "latitude",  :integer,                                :null => false
-      t.column "longitude", :integer,                                :null => false
-      t.column "user_id",   :bigint,   :limit => 20,                 :null => false
-      t.column "visible",   :boolean,                                :null => false
-      t.column "tags",      :text,                   :default => "", :null => false
-      t.column "timestamp", :datetime,                               :null => false
-      t.column "tile",      :integer,                                :null => false
+    create_table "nodes", :id => false do |t|
+      t.column "id",        :bigint, :null => false
+      t.column "latitude",  :integer, :null => false
+      t.column "longitude", :integer, :null => false
+      t.column "user_id",   :bigint, :null => false
+      t.column "visible",   :boolean, :null => false
+      t.column "tags",      :text, :default => "", :null => false
+      t.column "timestamp", :datetime, :null => false
+      t.column "tile",      :integer, :null => false
     end
 
     add_index "nodes", ["id"], :name => "nodes_uid_idx"
     add_index "nodes", ["timestamp"], :name => "nodes_timestamp_idx"
     add_index "nodes", ["tile"], :name => "nodes_tile_idx"
 
     end
 
     add_index "nodes", ["id"], :name => "nodes_uid_idx"
     add_index "nodes", ["timestamp"], :name => "nodes_timestamp_idx"
     add_index "nodes", ["tile"], :name => "nodes_tile_idx"
 
-    change_column "nodes", "tile", :four_byte_unsigned
+    change_column "nodes", "tile", :bigint
 
     upgrade_table "nodes_v5", "nodes", OldNode
 
 
     upgrade_table "nodes_v5", "nodes", OldNode
 
@@ -88,14 +88,14 @@ class TileNodes < ActiveRecord::Migration
   def self.down
     rename_table "current_nodes", "current_nodes_v6"
 
   def self.down
     rename_table "current_nodes", "current_nodes_v6"
 
-    create_table "current_nodes", innodb_table do |t|
-      t.column "id",        :bigint_pk_64,                           :null => false
-      t.column "latitude",  :double,                                 :null => false
-      t.column "longitude", :double,                                 :null => false
-      t.column "user_id",   :bigint,   :limit => 20,                 :null => false
-      t.column "visible",   :boolean,                                :null => false
-      t.column "tags",      :text,                   :default => "", :null => false
-      t.column "timestamp", :datetime,                               :null => false
+    create_table "current_nodes", :id => false do |t|
+      t.column "id",        :bigserial, :primary_key => true, :null => false
+      t.column "latitude",  :float, :limit => 53, :null => false
+      t.column "longitude", :float, :limit => 53, :null => false
+      t.column "user_id",   :bigint, :null => false
+      t.column "visible",   :boolean, :null => false
+      t.column "tags",      :text, :default => "", :null => false
+      t.column "timestamp", :datetime, :null => false
     end
 
     add_index "current_nodes", ["latitude", "longitude"], :name => "current_nodes_lat_lon_idx"
     end
 
     add_index "current_nodes", ["latitude", "longitude"], :name => "current_nodes_lat_lon_idx"
@@ -107,14 +107,14 @@ class TileNodes < ActiveRecord::Migration
 
     rename_table "nodes", "nodes_v6"
 
 
     rename_table "nodes", "nodes_v6"
 
-    create_table "nodes", myisam_table do |t|
-      t.column "id",        :bigint,   :limit => 64,                 :null => false
-      t.column "latitude",  :double,                                 :null => false
-      t.column "longitude", :double,                                 :null => false
-      t.column "user_id",   :bigint,   :limit => 20,                 :null => false
-      t.column "visible",   :boolean,                                :null => false
-      t.column "tags",      :text,                   :default => "", :null => false
-      t.column "timestamp", :datetime,                               :null => false
+    create_table "nodes", :id => false do |t|
+      t.column "id",        :bigint, :null => false
+      t.column "latitude",  :float, :limit => 53, :null => false
+      t.column "longitude", :float, :limit => 53, :null => false
+      t.column "user_id",   :bigint, :null => false
+      t.column "visible",   :boolean, :null => false
+      t.column "tags",      :text, :default => "", :null => false
+      t.column "timestamp", :datetime, :null => false
     end
 
     add_index "nodes", ["id"], :name => "nodes_uid_idx"
     end
 
     add_index "nodes", ["id"], :name => "nodes_uid_idx"
index 41d62928f1f6bd6a7e067cf06d558061f457d5f3..4a0f74c526b8aa181ccbd224cfed7edb4ab61a79 100644 (file)
@@ -9,10 +9,10 @@ class AddRelations < ActiveRecord::Migration
     # differences:
     # way: only nodes / relation: any kind of member
     # way: ordered sequence of nodes / relation: free-form "role" string
     # differences:
     # way: only nodes / relation: any kind of member
     # way: ordered sequence of nodes / relation: free-form "role" string
-    create_table "current_relation_members", innodb_table do |t|
-      t.column "id",          :bigint,   :limit => 64, :null => false
+    create_table "current_relation_members", :id => false do |t|
+      t.column "id",          :bigint, :null => false
       t.column "member_type", :nwr_enum, :null => false
       t.column "member_type", :nwr_enum, :null => false
-      t.column "member_id",   :bigint,   :limit => 11, :null => false
+      t.column "member_id",   :bigint, :null => false
       t.column "member_role", :string
     end
 
       t.column "member_role", :string
     end
 
@@ -20,57 +20,54 @@ class AddRelations < ActiveRecord::Migration
     add_index "current_relation_members", ["member_type", "member_id"], :name => "current_relation_members_member_idx"
     # the following is obsolete given the primary key, is it not?
     # add_index "current_relation_members", ["id"], :name => "current_relation_members_id_idx"
     add_index "current_relation_members", ["member_type", "member_id"], :name => "current_relation_members_member_idx"
     # the following is obsolete given the primary key, is it not?
     # add_index "current_relation_members", ["id"], :name => "current_relation_members_id_idx"
-    create_table "current_relation_tags", myisam_table do |t|
-      t.column "id", :bigint, :limit => 64, :null => false
+    create_table "current_relation_tags", :id => false do |t|
+      t.column "id", :bigint, :null => false
       t.column "k",  :string, :default => "", :null => false
       t.column "v",  :string, :default => "", :null => false
     end
 
     add_index "current_relation_tags", ["id"], :name => "current_relation_tags_id_idx"
       t.column "k",  :string, :default => "", :null => false
       t.column "v",  :string, :default => "", :null => false
     end
 
     add_index "current_relation_tags", ["id"], :name => "current_relation_tags_id_idx"
-    add_fulltext_index "current_relation_tags", "v"
+    add_index "current_relation_tags", "v", :name => "current_relation_tags_v_idx"
 
 
-    create_table "current_relations", innodb_table do |t|
-      t.column "id",        :bigint_pk_64,           :null => false
-      t.column "user_id",   :bigint,   :limit => 20, :null => false
+    create_table "current_relations", :id => false do |t|
+      t.column "id",        :bigserial, :primary_key => true, :null => false
+      t.column "user_id",   :bigint, :null => false
       t.column "timestamp", :datetime, :null => false
       t.column "timestamp", :datetime, :null => false
-      t.column "visible",   :boolean,  :null => false
+      t.column "visible",   :boolean, :null => false
     end
 
     end
 
-    create_table "relation_members", myisam_table do |t|
-      t.column "id",          :bigint,   :limit => 64, :default => 0, :null => false
+    create_table "relation_members", :id => false do |t|
+      t.column "id",          :bigint, :default => 0, :null => false
       t.column "member_type", :nwr_enum, :null => false
       t.column "member_type", :nwr_enum, :null => false
-      t.column "member_id",   :bigint,   :limit => 11, :null => false
+      t.column "member_id",   :bigint, :null => false
       t.column "member_role", :string
       t.column "member_role", :string
-      t.column "version",     :bigint,   :limit => 20, :default => 0, :null => false
+      t.column "version",     :bigint, :default => 0, :null => false
     end
 
     add_primary_key "relation_members", ["id", "version", "member_type", "member_id", "member_role"]
     add_index "relation_members", ["member_type", "member_id"], :name => "relation_members_member_idx"
 
     end
 
     add_primary_key "relation_members", ["id", "version", "member_type", "member_id", "member_role"]
     add_index "relation_members", ["member_type", "member_id"], :name => "relation_members_member_idx"
 
-    create_table "relation_tags", myisam_table do |t|
-      t.column "id",      :bigint,  :limit => 64, :default => 0, :null => false
+    create_table "relation_tags", :id => false do |t|
+      t.column "id",      :bigint, :default => 0, :null => false
       t.column "k",       :string, :null => false, :default => ""
       t.column "v",       :string, :null => false, :default => ""
       t.column "k",       :string, :null => false, :default => ""
       t.column "v",       :string, :null => false, :default => ""
-      t.column "version", :bigint,  :limit => 20, :null => false
+      t.column "version", :bigint, :null => false
     end
 
     add_index "relation_tags", ["id", "version"], :name => "relation_tags_id_version_idx"
 
     end
 
     add_index "relation_tags", ["id", "version"], :name => "relation_tags_id_version_idx"
 
-    create_table "relations", myisam_table do |t|
-      t.column "id",        :bigint,   :limit => 64, :null => false, :default => 0
-      t.column "user_id",   :bigint,   :limit => 20, :null => false
-      t.column "timestamp", :datetime,               :null => false
-      t.column "version",   :bigint,   :limit => 20, :null => false
-      t.column "visible",   :boolean,                :null => false, :default => true
+    create_table "relations", :id => false do |t|
+      t.column "id",        :bigint, :null => false, :default => 0
+      t.column "user_id",   :bigint, :null => false
+      t.column "timestamp", :datetime, :null => false
+      t.column "version",   :bigint, :null => false
+      t.column "visible",   :boolean, :null => false, :default => true
     end
 
     add_primary_key "relations", ["id", "version"]
     add_index "relations", ["timestamp"], :name => "relations_timestamp_idx"
     end
 
     add_primary_key "relations", ["id", "version"]
     add_index "relations", ["timestamp"], :name => "relations_timestamp_idx"
-    
-    change_column "relations", "version", :bigint_auto_20
   end
 
   end
 
-
   def self.down
     drop_table :relations
     drop_table :current_relations
   def self.down
     drop_table :relations
     drop_table :current_relations
index ce49e9ccaf4e76608065d8968a52a7a15c84e72f..0c68ce0509e11be3e7220ed4fe417ed8c176dbf0 100644 (file)
@@ -28,20 +28,20 @@ class RemoveSegments < ActiveRecord::Migration
 
     drop_table :segments
     drop_table :way_segments
 
     drop_table :segments
     drop_table :way_segments
-    create_table :way_nodes, myisam_table do |t|
-      t.column :id,          :bigint, :limit => 64, :null => false
-      t.column :node_id,     :bigint, :limit => 64, :null => false
-      t.column :version,     :bigint, :limit => 20, :null => false
-      t.column :sequence_id, :bigint, :limit => 11, :null => false
+    create_table :way_nodes, :id => false do |t|
+      t.column :id,          :bigint, :null => false
+      t.column :node_id,     :bigint, :null => false
+      t.column :version,     :bigint, :null => false
+      t.column :sequence_id, :bigint, :null => false
     end
     add_primary_key :way_nodes, [:id, :version, :sequence_id]
 
     drop_table :current_segments
     drop_table :current_way_segments
     end
     add_primary_key :way_nodes, [:id, :version, :sequence_id]
 
     drop_table :current_segments
     drop_table :current_way_segments
-    create_table :current_way_nodes, innodb_table do |t|
-      t.column :id,          :bigint, :limit => 64, :null => false
-      t.column :node_id,     :bigint, :limit => 64, :null => false
-      t.column :sequence_id, :bigint, :limit => 11, :null => false
+    create_table :current_way_nodes, :id => false do |t|
+      t.column :id,          :bigint, :null => false
+      t.column :node_id,     :bigint, :null => false
+      t.column :sequence_id, :bigint, :null => false
     end
     add_primary_key :current_way_nodes, [:id, :sequence_id]
     add_index :current_way_nodes, [:node_id], :name => "current_way_nodes_node_idx"
     end
     add_primary_key :current_way_nodes, [:id, :sequence_id]
     add_index :current_way_nodes, [:node_id], :name => "current_way_nodes_node_idx"
index ecad2f5dcd50478217ba569baa9d268c6fcce7e2..ad2edffa43ebb57c4fadc038663777baec9ce058 100644 (file)
@@ -2,13 +2,13 @@ require 'migrate'
 
 class DiaryComments < ActiveRecord::Migration
   def self.up
 
 class DiaryComments < ActiveRecord::Migration
   def self.up
-    create_table "diary_comments", myisam_table do |t|
-      t.column "id",             :bigint_pk,              :null => false
-      t.column "diary_entry_id", :bigint,   :limit => 20, :null => false
-      t.column "user_id",        :bigint,   :limit => 20, :null => false
-      t.column "body",           :text,                   :null => false
-      t.column "created_at",     :datetime,               :null => false
-      t.column "updated_at",     :datetime,               :null => false
+    create_table "diary_comments", :id => false do |t|
+      t.column "id",             :bigserial, :primary_key => true, :null => false
+      t.column "diary_entry_id", :bigint, :null => false
+      t.column "user_id",        :bigint, :null => false
+      t.column "body",           :text, :null => false
+      t.column "created_at",     :datetime, :null => false
+      t.column "updated_at",     :datetime, :null => false
     end
 
     add_index "diary_comments", ["diary_entry_id", "id"], :name => "diary_comments_entry_id_idx", :unique => true
     end
 
     add_index "diary_comments", ["diary_entry_id", "id"], :name => "diary_comments_entry_id_idx", :unique => true
index 08ed4f7316b8b9fad91873b7d0c067c91e0d5373..0db06f30cba4978b8ee73ba23bacae8d8d7cc990 100644 (file)
@@ -2,11 +2,11 @@ require 'migrate'
 
 class CreateAcls < ActiveRecord::Migration
   def self.up
 
 class CreateAcls < ActiveRecord::Migration
   def self.up
-    create_table "acls", myisam_table do |t|
-      t.column "id",      :integer_pk, :null => false
-      t.column "address", :inet,       :null => false
-      t.column "netmask", :inet,       :null => false
-      t.column "k",       :string,     :null => false
+    create_table "acls", :id => false do |t|
+      t.column "id",      :primary_key, :null => false
+      t.column "address", :inet, :null => false
+      t.column "netmask", :inet, :null => false
+      t.column "k",       :string, :null => false
       t.column "v",       :string
     end
 
       t.column "v",       :string
     end
 
index 4c9628f2700cf8cda16f6369229161b4b2b1b776..8fa7b7e5d32d1f1504b6886bc4bdba69f075d0a0 100644 (file)
@@ -27,17 +27,17 @@ class PopulateNodeTagsAndRemove < ActiveRecord::Migration
     remove_column :nodes, :tags
     remove_column :current_nodes, :tags
 
     remove_column :nodes, :tags
     remove_column :current_nodes, :tags
 
-    add_column :nodes, :version, :bigint, :limit => 20, :null => false
+    add_column :nodes, :version, :bigint, :null => false
 
 
-    create_table :current_node_tags, innodb_table do |t|
-      t.column :id,          :bigint, :limit => 64, :null => false
+    create_table :current_node_tags, :id => false do |t|
+      t.column :id,          :bigint, :null => false
       t.column :k,          :string, :default => "", :null => false
       t.column :v,          :string, :default => "", :null => false
     end
 
       t.column :k,          :string, :default => "", :null => false
       t.column :v,          :string, :default => "", :null => false
     end
 
-    create_table :node_tags, innodb_table do |t|
-      t.column :id,          :bigint, :limit => 64, :null => false
-      t.column :version,     :bigint, :limit => 20, :null => false
+    create_table :node_tags, :id => false do |t|
+      t.column :id,          :bigint, :null => false
+      t.column :version,     :bigint, :null => false
       t.column :k,          :string, :default => "", :null => false
       t.column :v,          :string, :default => "", :null => false
     end
       t.column :k,          :string, :default => "", :null => false
       t.column :v,          :string, :default => "", :null => false
     end
index f9110cca67e676c0613f96f1915577604115459a..030515a98ec34ee03ae45f642083378ea48cd606 100644 (file)
@@ -12,15 +12,11 @@ class MoveToInnodb < ActiveRecord::Migration
     remove_index :current_relation_tags, :name=> :current_relation_tags_v_idx
 
     @@ver_tbl.each { |tbl|
     remove_index :current_relation_tags, :name=> :current_relation_tags_v_idx
 
     @@ver_tbl.each { |tbl|
-      change_column tbl, "version", :bigint, :limit => 20, :null => false
-    }
-
-    @@conv_tables.each { |tbl|
-      change_engine tbl, "InnoDB"
+      change_column tbl, "version", :bigint, :null => false
     }
 
     @@ver_tbl.each { |tbl|
     }
 
     @@ver_tbl.each { |tbl|
-      add_column "current_#{tbl}", "version", :bigint, :limit => 20, :null => false
+      add_column "current_#{tbl}", "version", :bigint, :null => false
       # As the initial version of all nodes, ways and relations is 0, we set the 
       # current version to something less so that we can update the version in 
       # batches of 10000
       # As the initial version of all nodes, ways and relations is 0, we set the 
       # current version to something less so that we can update the version in 
       # batches of 10000
index f94c965bb087dc8501378cc2efb92acb47649865..e854ba78e0dd6075f9404c0075ad5fa746abe240 100644 (file)
@@ -23,21 +23,21 @@ class KeyConstraints < ActiveRecord::Migration
     remove_index :nodes, :name => :nodes_uid_idx
 
     # Foreign keys (between ways, way_tags, way_nodes, etc.)
     remove_index :nodes, :name => :nodes_uid_idx
 
     # Foreign keys (between ways, way_tags, way_nodes, etc.)
-    add_foreign_key :current_node_tags, [:id], :current_nodes
-    add_foreign_key :node_tags, [:id, :version], :nodes
+    add_foreign_key :current_node_tags, :current_nodes, :column => :id, :name => "current_node_tags_id_fkey"
+    add_foreign_key :node_tags, :nodes, :column => [:id, :version], :primary_key => [:id, :version], :name => "node_tags_id_fkey"
 
 
-    add_foreign_key :current_way_tags, [:id], :current_ways
-    add_foreign_key :current_way_nodes, [:id], :current_ways
-    add_foreign_key :way_tags, [:id, :version], :ways
-    add_foreign_key :way_nodes, [:id, :version], :ways
+    add_foreign_key :current_way_tags, :current_ways, :column => :id, :name => "current_way_tags_id_fkey"
+    add_foreign_key :current_way_nodes, :current_ways, :column => :id, :name => "current_way_nodes_id_fkey"
+    add_foreign_key :way_tags, :ways, :column => [:id, :version], :primary_key => [:id, :version], :name => "way_tags_id_fkey"
+    add_foreign_key :way_nodes, :ways, :column => [:id, :version], :primary_key => [:id, :version], :name => "way_nodes_id_fkey"
 
 
-    add_foreign_key :current_relation_tags, [:id], :current_relations
-    add_foreign_key :current_relation_members, [:id], :current_relations
-    add_foreign_key :relation_tags, [:id, :version], :relations
-    add_foreign_key :relation_members, [:id, :version], :relations
+    add_foreign_key :current_relation_tags, :current_relations, :column => :id, :name => "current_relation_tags_id_fkey"
+    add_foreign_key :current_relation_members, :current_relations, :column => :id, :name => "current_relation_members_id_fkey"
+    add_foreign_key :relation_tags, :relations, :column => [:id, :version], :primary_key => [:id, :version], :name => "relation_tags_id_fkey"
+    add_foreign_key :relation_members, :relations, :column => [:id, :version], :primary_key => [:id, :version], :name => "relation_members_id_fkey"
 
     # Foreign keys (between different types of primitives)
 
     # Foreign keys (between different types of primitives)
-    add_foreign_key :current_way_nodes, [:node_id], :current_nodes, [:id]
+    add_foreign_key :current_way_nodes, :current_nodes, :column => :node_id, :name => "current_way_nodes_node_id_fkey"
 
     # FIXME: We don't have foreign keys for relation members since the id
     # might point to a different table depending on the `type' column.
 
     # FIXME: We don't have foreign keys for relation members since the id
     # might point to a different table depending on the `type' column.
index 5bee215122e23f21c415a77ad8471821d0a915c1..3a6c32e19a4151539431c8482e4a85806ee54ffc 100644 (file)
@@ -5,19 +5,19 @@ class AddChangesets < ActiveRecord::Migration
   'current_relations', 'current_ways', 'nodes', 'relations', 'ways' ]
   
   def self.up
   'current_relations', 'current_ways', 'nodes', 'relations', 'ways' ]
   
   def self.up
-    create_table "changesets", innodb_table do |t|
-      t.column "id",             :bigint_pk,              :null => false
-      t.column "user_id",        :bigint,   :limit => 20, :null => false
-      t.column "created_at",     :datetime,               :null => false
-      t.column "open",           :boolean,                :null => false, :default => true
-      t.column "min_lat",        :integer,                :null => true
-      t.column "max_lat",        :integer,                :null => true
-      t.column "min_lon",        :integer,                :null => true
-      t.column "max_lon",        :integer,                :null => true
+    create_table "changesets", :id => false do |t|
+      t.column "id",             :bigserial, :primary_key => true, :null => false
+      t.column "user_id",        :bigint, :null => false
+      t.column "created_at",     :datetime, :null => false
+      t.column "open",           :boolean, :null => false, :default => true
+      t.column "min_lat",        :integer, :null => true
+      t.column "max_lat",        :integer, :null => true
+      t.column "min_lon",        :integer, :null => true
+      t.column "max_lon",        :integer, :null => true
     end
 
     end
 
-    create_table "changeset_tags", innodb_table do |t|
-      t.column "id", :bigint, :limit => 64, :null => false
+    create_table "changeset_tags", :id => false do |t|
+      t.column "id", :bigint, :null => false
       t.column "k",  :string, :default => "", :null => false
       t.column "v",  :string, :default => "", :null => false
     end
       t.column "k",  :string, :default => "", :null => false
       t.column "v",  :string, :default => "", :null => false
     end
@@ -35,7 +35,7 @@ class AddChangesets < ActiveRecord::Migration
     @@conv_user_tables.each { |tbl|
       rename_column tbl, :user_id, :changeset_id
       #foreign keys too
     @@conv_user_tables.each { |tbl|
       rename_column tbl, :user_id, :changeset_id
       #foreign keys too
-      add_foreign_key tbl, [:changeset_id], :changesets, [:id]
+      add_foreign_key tbl, :changesets, :name => "#{tbl}_changeset_id_fkey"
     }
   end
 
     }
   end
 
index eaccc008f7666d38713a6e110658a1d6095715da..32d27959a44cc212813d8383b116fdfa84251af6 100644 (file)
@@ -9,8 +9,8 @@ class AddEndTimeToChangesets < ActiveRecord::Migration
     # it appears that execute will only accept string arguments, so
     # this is an ugly, ugly hack to get some sort of mysql/postgres
     # independence. now i have to go wash my brain with bleach.
     # it appears that execute will only accept string arguments, so
     # this is an ugly, ugly hack to get some sort of mysql/postgres
     # independence. now i have to go wash my brain with bleach.
-    execute("update changesets set closed_at=(now()-#{interval_constant('1 hour')}) where open=(1=0)")
-    execute("update changesets set closed_at=(now()+#{interval_constant('1 hour')}) where open=(1=1)")
+    execute("update changesets set closed_at=(now()-'1 hour'::interval) where open=(1=0)")
+    execute("update changesets set closed_at=(now()+'1 hour'::interval) where open=(1=1)")
 
     # remove the open column as it is unnecessary now and denormalises 
     # the table.
 
     # remove the open column as it is unnecessary now and denormalises 
     # the table.
index 45d014e9e51a81115ea4eb8a9cdc260382709bb8..ea2dc0290f3d891e4479b5125ca6500616c92428 100644 (file)
@@ -4,7 +4,7 @@ class AddMoreChangesetIndexes < ActiveRecord::Migration
   def self.up
     add_index "changesets", ["created_at"], :name => "changesets_created_at_idx"
     add_index "changesets", ["closed_at"], :name => "changesets_closed_at_idx"
   def self.up
     add_index "changesets", ["created_at"], :name => "changesets_created_at_idx"
     add_index "changesets", ["closed_at"], :name => "changesets_closed_at_idx"
-    add_index "changesets", ["min_lat","max_lat","min_lon","max_lon"], :name => "changesets_bbox_idx", :method => "GIST"
+    add_index "changesets", ["min_lat","max_lat","min_lon","max_lon"], :name => "changesets_bbox_idx", :using => "GIST"
   end
 
   def self.down
   end
 
   def self.down
index cb0d9e1dddc5fd0b4cb870f370e8b2942f61b6f0..5d3532c72dfd7a976a0495d2e0f5cb1394988fce 100644 (file)
@@ -1,20 +1,16 @@
 require 'migrate'
 
 class AddUserForeignKeys < ActiveRecord::Migration
 require 'migrate'
 
 class AddUserForeignKeys < ActiveRecord::Migration
-  def self.up
-    add_foreign_key :changesets, [:user_id], :users, [:id]
-    add_foreign_key :diary_comments, [:user_id], :users, [:id]
-    add_foreign_key :diary_entries, [:user_id], :users, [:id]
-    add_foreign_key :friends, [:user_id], :users, [:id]
-    add_foreign_key :friends, [:friend_user_id], :users, [:id]
-    add_foreign_key :gpx_files, [:user_id], :users, [:id]
-    add_foreign_key :messages, [:from_user_id], :users, [:id]
-    add_foreign_key :messages, [:to_user_id], :users, [:id]
-    add_foreign_key :user_preferences, [:user_id], :users, [:id]
-    add_foreign_key :user_tokens, [:user_id], :users, [:id]
-  end
-
-  def self.down
-    raise ActiveRecord::IrreversibleMigration
+  def change
+    add_foreign_key :changesets, :users, :name => "changesets_user_id_fkey"
+    add_foreign_key :diary_comments, :users, :name => "diary_comments_user_id_fkey"
+    add_foreign_key :diary_entries, :users, :name => "diary_entries_user_id_fkey"
+    add_foreign_key :friends, :users, :name => "friends_user_id_fkey"
+    add_foreign_key :friends, :users, :column => :friend_user_id, :name => "friends_friend_user_id_fkey"
+    add_foreign_key :gpx_files, :users, :name => "gpx_files_user_id_fkey"
+    add_foreign_key :messages, :users, :column => :from_user_id, :name => "messages_from_user_id_fkey"
+    add_foreign_key :messages, :users, :column => :to_user_id, :name => "messages_to_user_id_fkey"
+    add_foreign_key :user_preferences, :users, :name => "user_preferences_user_id_fkey"
+    add_foreign_key :user_tokens, :users, :name => "user_tokens_user_id_fkey"
   end
 end
   end
 end
index e3dc7e82ddd566b974b01e7e6915b4562cb5a302..1b99f664de9bae15ba00cdfe66a500840a7dc75a 100644 (file)
@@ -2,10 +2,10 @@ require 'migrate'
 
 class AddForeignKeys < ActiveRecord::Migration
   def self.up
 
 class AddForeignKeys < ActiveRecord::Migration
   def self.up
-    add_foreign_key :changeset_tags, [:id], :changesets
-    add_foreign_key :diary_comments, [:diary_entry_id], :diary_entries, [:id]
-    add_foreign_key :gps_points, [:gpx_id], :gpx_files, [:id]
-    add_foreign_key :gpx_file_tags, [:gpx_id], :gpx_files, [:id]
+    add_foreign_key :changeset_tags, :changesets, :column => :id, :name => "changeset_tags_id_fkey"
+    add_foreign_key :diary_comments, :diary_entries, :name => "diary_comments_diary_entry_id_fkey"
+    add_foreign_key :gps_points, :gpx_files, :column => :gpx_id, :name => "gps_points_gpx_id_fkey"
+    add_foreign_key :gpx_file_tags, :gpx_files, :column => :gpx_id, :name => "gpx_file_tags_gpx_id_fkey"
   end
 
   def self.down
   end
 
   def self.down
index 923d943f7915671a921404738c1e56e955ad7fef..c0b4fb634abeafe5224851b585087b12ba8a309f 100644 (file)
@@ -3,13 +3,13 @@ require 'rexml/document'
 
 class CreateCountries < ActiveRecord::Migration
   def self.up
 
 class CreateCountries < ActiveRecord::Migration
   def self.up
-    create_table :countries, innodb_table do |t|
-      t.column :id,      :integer_pk,              :null => false
-      t.column :code,    :string,     :limit => 2, :null => false
-      t.column :min_lat, :double,                  :null => false
-      t.column :max_lat, :double,                  :null => false
-      t.column :min_lon, :double,                  :null => false
-      t.column :max_lon, :double,                  :null => false
+    create_table :countries, :id => false do |t|
+      t.column :id,      :primary_key, :null => false
+      t.column :code,    :string, :limit => 2, :null => false
+      t.column :min_lat, :float, :limit => 53, :null => false
+      t.column :max_lat, :float, :limit => 53, :null => false
+      t.column :min_lon, :float, :limit => 53, :null => false
+      t.column :max_lon, :float, :limit => 53, :null => false
     end
 
     add_index :countries, [:code], :name => "countries_code_idx", :unique => true
     end
 
     add_index :countries, [:code], :name => "countries_code_idx", :unique => true
index e62a3dff9cbe82c415033248f4753ff0086e24a0..a9d6831515e3eaeff32e132963d288067ae1e073 100644 (file)
@@ -1,8 +1,8 @@
 require 'migrate'
 
 class CreateLanguages < ActiveRecord::Migration
 require 'migrate'
 
 class CreateLanguages < ActiveRecord::Migration
-  def self.up
-    create_table :languages, innodb_table do |t|
+  def change
+    create_table :languages, :id => false do |t|
       t.string :code, :null => false
       t.string :english_name, :null => false
       t.string :native_name
       t.string :code, :null => false
       t.string :english_name, :null => false
       t.string :native_name
@@ -12,11 +12,7 @@ class CreateLanguages < ActiveRecord::Migration
 
     Language.load("#{Rails.root}/config/languages.yml")
 
 
     Language.load("#{Rails.root}/config/languages.yml")
 
-    add_foreign_key :users, [:locale], :languages, [:code]
-    add_foreign_key :diary_entries, [:language_code], :languages, [:code]    
-  end
-
-  def self.down
-    raise ActiveRecord::IrreversibleMigration
+    add_foreign_key :users, :languages, :column => :locale, :primary_key => :code, :name => "users_locale_fkey"
+    add_foreign_key :diary_entries, :languages, :column => :language_code , :primary_key => :code, :name => "diary_entries_language_code_fkey"
   end
 end
   end
 end
index bfb43056a5bc741285aaa36c0ff05f2fc8ef163f..117e1cd0cec7b813e10a49c9c40c95ae1fc64135 100644 (file)
@@ -2,7 +2,7 @@ require 'migrate'
 
 class ChangeUserLocale < ActiveRecord::Migration
   def self.up
 
 class ChangeUserLocale < ActiveRecord::Migration
   def self.up
-    remove_foreign_key :users, [:locale], :languages, [:code]
+    remove_foreign_key :users, :column => :locale, :name => "users_locale_fkey"
 
     rename_column :users, :locale, :languages
   end
 
     rename_column :users, :locale, :languages
   end
@@ -10,6 +10,6 @@ class ChangeUserLocale < ActiveRecord::Migration
   def self.down
     rename_column :users, :languages, :locale
 
   def self.down
     rename_column :users, :languages, :locale
 
-    add_foreign_key :users, [:locale], :languages, [:code]
+    add_foreign_key :users, :languages, :column => :locale, :primary_key => :code, :name => "users_locale_fkey"
   end
 end
   end
 end
index ee8048a36328f975371db0281e36af20a7ac1eb2..abc4e9c517b80de30aac93412d7a00de58df00f9 100644 (file)
@@ -1,15 +1,9 @@
 require 'migrate'
 
 class AddForeignKeysToOauthTables < ActiveRecord::Migration
 require 'migrate'
 
 class AddForeignKeysToOauthTables < ActiveRecord::Migration
-  def self.up
-    add_foreign_key :oauth_tokens, [:user_id], :users, [:id]
-    add_foreign_key :oauth_tokens, [:client_application_id], :client_applications, [:id]
-    add_foreign_key :client_applications, [:user_id], :users, [:id]
-  end
-
-  def self.down
-    remove_foreign_key :oauth_tokens, [:user_id], :users
-    remove_foreign_key :oauth_tokens, [:client_application_id], :client_applications
-    remove_foreign_key :client_applications, [:user_id], :users
+  def change
+    add_foreign_key :oauth_tokens, :users, :name => "oauth_tokens_user_id_fkey"
+    add_foreign_key :oauth_tokens, :client_applications, :name => "oauth_tokens_client_application_id_fkey"
+    add_foreign_key :client_applications, :users, :name => "client_applications_user_id_fkey"
   end
 end
   end
 end
index 0db3ea77e5fc01976419aa297ddad97b3b5b6152..26b2adf6fdbf4b67eb71dcf8f50d85ac2ddfecf9 100644 (file)
@@ -6,26 +6,29 @@ class CreateUserRoles < ActiveRecord::Migration
 
     create_table :user_roles do |t|
       t.column :user_id, :bigint, :null => false
 
     create_table :user_roles do |t|
       t.column :user_id, :bigint, :null => false
+      t.column :role, :user_role_enum, :null => false
 
       t.timestamps
     end
 
       t.timestamps
     end
-    add_column :user_roles, :role, :user_role_enum, :null => false
 
     User.where(:administrator => true).each do |user|
       UserRole.create(:user_id => user.id, :role => "administrator")
     end
 
     User.where(:administrator => true).each do |user|
       UserRole.create(:user_id => user.id, :role => "administrator")
     end
+
     remove_column :users, :administrator
 
     remove_column :users, :administrator
 
-    add_foreign_key :user_roles, [:user_id], :users, [:id]
+    add_foreign_key :user_roles, :users, :name => "user_roles_user_id_fkey"
   end
 
   def self.down
     add_column :users, :administrator, :boolean, :default => false, :null => false
   end
 
   def self.down
     add_column :users, :administrator, :boolean, :default => false, :null => false
+
     UserRole.where(:role => "administrator").each do |role|
       user = User.find(role.user_id)
       user.administrator = true
       user.save!
     end
     UserRole.where(:role => "administrator").each do |role|
       user = User.find(role.user_id)
       user.administrator = true
       user.save!
     end
+
     drop_table :user_roles
     drop_enumeration :user_role_enum
   end
     drop_table :user_roles
     drop_enumeration :user_role_enum
   end
index b3313ce921ccf3ef976b97a87bb041897d082f37..e97822a0dbf3c2d3f152e55056bacc83ed81f5c0 100644 (file)
@@ -1,7 +1,7 @@
 require 'migrate'
 
 class CreateUserBlocks < ActiveRecord::Migration
 require 'migrate'
 
 class CreateUserBlocks < ActiveRecord::Migration
-  def self.up
+  def change
     create_table :user_blocks do |t|
       t.column :user_id,      :bigint,   :null => false
       t.column :moderator_id, :bigint,   :null => false
     create_table :user_blocks do |t|
       t.column :user_id,      :bigint,   :null => false
       t.column :moderator_id, :bigint,   :null => false
@@ -13,14 +13,10 @@ class CreateUserBlocks < ActiveRecord::Migration
       t.timestamps
     end
 
       t.timestamps
     end
 
-    add_foreign_key :user_blocks, [:user_id], :users, [:id]
-    add_foreign_key :user_blocks, [:moderator_id], :users, [:id]
-    add_foreign_key :user_blocks, [:revoker_id], :users, [:id]
+    add_foreign_key :user_blocks, :users, :name => "user_blocks_user_id_fkey"
+    add_foreign_key :user_blocks, :users, :column => :moderator_id, :name => "user_blocks_moderator_id_fkey"
+    add_foreign_key :user_blocks, :users, :column => :revoker_id, :name => "user_blocks_revoker_id_fkey"
 
     add_index :user_blocks, [:user_id]
   end
 
     add_index :user_blocks, [:user_id]
   end
-
-  def self.down
-    drop_table :user_blocks
-  end
 end
 end
index 9799e4e5ec5f0ea7f7dc3c7e8c4f5d4514547f19..864f0db5de95dc168611b3a451f1d4d9e37d0e42 100644 (file)
@@ -8,7 +8,7 @@ class AlterUserRolesAndBlocks < ActiveRecord::Migration
     add_column :user_roles, :granter_id, :bigint
     UserRole.update_all("granter_id = user_id")
     change_column :user_roles, :granter_id, :bigint, :null => false
     add_column :user_roles, :granter_id, :bigint
     UserRole.update_all("granter_id = user_id")
     change_column :user_roles, :granter_id, :bigint, :null => false
-    add_foreign_key :user_roles, [:granter_id], :users, [:id]
+    add_foreign_key :user_roles, :users, :column => :granter_id, :name => "user_roles_granter_id_fkey"
 
     # make sure that [user_id, role] is unique
     add_index :user_roles, [:user_id, :role], :name => "user_roles_id_role_unique", :unique => true
 
     # make sure that [user_id, role] is unique
     add_index :user_roles, [:user_id, :role], :name => "user_roles_id_role_unique", :unique => true
@@ -21,9 +21,9 @@ class AlterUserRolesAndBlocks < ActiveRecord::Migration
   end
 
   def self.down
   end
 
   def self.down
-    remove_column :user_roles, :granter_id
-    remove_index :user_roles, :name => "user_roles_id_role_unique"
-    rename_column :user_blocks, :creator_id, :moderator_id
     rename_column :user_blocks, :ends_at, :end_at
     rename_column :user_blocks, :ends_at, :end_at
+    rename_column :user_blocks, :creator_id, :moderator_id
+    remove_index :user_roles, :name => "user_roles_id_role_unique"
+    remove_column :user_roles, :granter_id
   end
 end
   end
 end
index d94105035551c3739af29832d28d5deee1e8af32..d3839aaa87a72a4e802604a176694915bb24870c 100644 (file)
@@ -18,13 +18,13 @@ class RefactorMapBugTables < ActiveRecord::Migration
 
     add_index :map_bug_comment, [:bug_id], :name => "map_bug_comment_id_idx"
 
 
     add_index :map_bug_comment, [:bug_id], :name => "map_bug_comment_id_idx"
 
-    add_foreign_key :map_bug_comment, [:bug_id], :map_bugs, [:id]
-    add_foreign_key :map_bug_comment, [:commenter_id], :users, [:id]
+    add_foreign_key :map_bug_comment, :map_bugs, :column => :bug_id, :name => "note_comments_note_id_fkey"
+    add_foreign_key :map_bug_comment, :users, :column => :commenter_id, :name => "note_comments_author_id_fkey"
   end
 
   def self.down
   end
 
   def self.down
-    remove_foreign_key :map_bug_comment, [:commenter_id]
-    remove_foreign_key :map_bug_comment, [:bug_id]
+    remove_foreign_key :map_bug_comment, :users, :column => :commenter_id, :name => "note_comments_author_id_fkey"
+    remove_foreign_key :map_bug_comment, :map_bugs, :column => :bug_id, :name => "note_comments_note_id_fkey"
 
     remove_index :map_bugs, :name => "map_bug_comment_id_idx"
 
 
     remove_index :map_bugs, :name => "map_bug_comment_id_idx"
 
index 2934b73fd7a978b74885dee9413d282a19bea9aa..5b9933e04cb5edef97b52ba573aa0ac43fa67451 100644 (file)
@@ -6,43 +6,23 @@ class RenameBugsToNotes < ActiveRecord::Migration
     rename_enumeration "map_bug_event_enum", "note_event_enum"
 
     rename_table :map_bugs, :notes
     rename_enumeration "map_bug_event_enum", "note_event_enum"
 
     rename_table :map_bugs, :notes
-    rename_index :notes, "map_bugs_pkey", "notes_pkey"
     rename_index :notes, "map_bugs_changed_idx", "notes_updated_at_idx"
     rename_index :notes, "map_bugs_created_idx", "notes_created_at_idx"
     rename_index :notes, "map_bugs_tile_idx", "notes_tile_status_idx"
 
     rename_index :notes, "map_bugs_changed_idx", "notes_updated_at_idx"
     rename_index :notes, "map_bugs_created_idx", "notes_created_at_idx"
     rename_index :notes, "map_bugs_tile_idx", "notes_tile_status_idx"
 
-    remove_foreign_key :map_bug_comment, [:bug_id], :map_bugs, [:id]
-    rename_column :map_bug_comment, :author_id, :commenter_id
-    remove_foreign_key :map_bug_comment, [:commenter_id], :users, [:id]
-    rename_column :map_bug_comment, :commenter_id, :author_id
-
     rename_table :map_bug_comment, :note_comments
     rename_column :note_comments, :bug_id, :note_id
     rename_table :map_bug_comment, :note_comments
     rename_column :note_comments, :bug_id, :note_id
-    rename_index :note_comments, "map_bug_comment_pkey", "note_comments_pkey"
     rename_index :note_comments, "map_bug_comment_id_idx", "note_comments_note_id_idx"
     rename_index :note_comments, "map_bug_comment_id_idx", "note_comments_note_id_idx"
-
-    add_foreign_key :note_comments, [:note_id], :notes, [:id]
-    add_foreign_key :note_comments, [:author_id], :users, [:id]
   end
 
   def self.down
   end
 
   def self.down
-    remove_foreign_key :note_comments, [:author_id], :users, [:id]
-    remove_foreign_key :note_comments, [:note_id], :notes, [:id]
-
     rename_index :note_comments, "note_comments_note_id_idx", "map_bug_comment_id_idx"
     rename_index :note_comments, "note_comments_note_id_idx", "map_bug_comment_id_idx"
-    rename_index :notes, "note_comments_pkey", "map_bug_comment_pkey"
     rename_column :note_comments, :note_id, :bug_id
     rename_table :note_comments, :map_bug_comment
 
     rename_column :note_comments, :note_id, :bug_id
     rename_table :note_comments, :map_bug_comment
 
-    rename_column :map_bug_comment, :author_id, :commenter_id
-    add_foreign_key :map_bug_comment, [:commenter_id], :users, [:id]
-    rename_column :map_bug_comment, :commenter_id, :author_id
-    add_foreign_key :map_bug_comment, [:bug_id], :notes, [:id]
-
     rename_index :notes, "notes_tile_status_idx", "map_bugs_tile_idx"
     rename_index :notes, "notes_created_at_idx", "map_bugs_created_idx"
     rename_index :notes, "notes_updated_at_idx", "map_bugs_changed_idx"
     rename_index :notes, "notes_tile_status_idx", "map_bugs_tile_idx"
     rename_index :notes, "notes_created_at_idx", "map_bugs_created_idx"
     rename_index :notes, "notes_updated_at_idx", "map_bugs_changed_idx"
-    rename_index :notes, "notes_pkey", "map_bugs_pkey"
     rename_table :notes, :map_bugs
 
     rename_enumeration "note_event_enum", "map_bug_event_enum"
     rename_table :notes, :map_bugs
 
     rename_enumeration "note_event_enum", "map_bug_event_enum"
index 4142a642d65ca93ca55c232094e5624481fa3f8a..69e7ed2995253b3279d3f39415897cf00916d1d7 100644 (file)
@@ -2,8 +2,8 @@ require 'migrate'
 
 class AddLowercaseUserIndexes < ActiveRecord::Migration
   def up
 
 class AddLowercaseUserIndexes < ActiveRecord::Migration
   def up
-    add_index :users, :display_name, :lowercase => true, :name => "users_display_name_lower_idx"
-    add_index :users, :email, :lowercase => true, :name => "users_email_lower_idx"
+    add_index :users, [], :columns => "LOWER(display_name)", :name => "users_display_name_lower_idx"
+    add_index :users, [], :columns => "LOWER(email)", :name => "users_email_lower_idx"
   end
 
   def down
   end
 
   def down
index b6ee96037948205745635aca949a9e4d73da76db..15cc1e13b8c6576d09128b76f36e35eec1ddb9d6 100644 (file)
@@ -1,7 +1,7 @@
 require 'migrate'
 
 class CreateRedactions < ActiveRecord::Migration
 require 'migrate'
 
 class CreateRedactions < ActiveRecord::Migration
-  def up
+  def change
     create_table :redactions do |t|
       t.string :title
       t.text :description
     create_table :redactions do |t|
       t.string :title
       t.text :description
@@ -11,16 +11,7 @@ class CreateRedactions < ActiveRecord::Migration
 
     [:nodes, :ways, :relations].each do |tbl|
       add_column tbl, :redaction_id, :integer, :null => true
 
     [:nodes, :ways, :relations].each do |tbl|
       add_column tbl, :redaction_id, :integer, :null => true
-      add_foreign_key tbl, [:redaction_id], :redactions, [:id]
+      add_foreign_key tbl, :redactions, :name => "#{tbl}_redaction_id_fkey"
     end
   end
     end
   end
-
-  def down
-    [:nodes, :ways, :relations].each do |tbl|
-      remove_foreign_key tbl, [:redaction_id], :redactions, [:id]
-      remove_column tbl, :redaction_id
-    end
-
-    drop_table :redactions
-  end
 end
 end
index e5f9739a54e9582aa711b59e57c35e86d2d3b9d0..627db6d7c09c3284c23d38b5b51d42b8bb9e842c 100644 (file)
@@ -6,7 +6,7 @@ class DropSessionTable < ActiveRecord::Migration
   end
 
   def down
   end
 
   def down
-    create_table "sessions", :options => innodb_option do |t|
+    create_table "sessions" do |t|
       t.column "session_id", :string
       t.column "data",       :text
       t.column "created_at", :timestamp
       t.column "session_id", :string
       t.column "data",       :text
       t.column "created_at", :timestamp
index 05c75d37e43b7e7c12c92c64920f4437cca166e1..0ca0be4a0ee9398ae546d76306ed8908208b1985 100644 (file)
@@ -1,17 +1,10 @@
 require 'migrate'
 
 class AddUserAndDescriptionToRedaction < ActiveRecord::Migration
 require 'migrate'
 
 class AddUserAndDescriptionToRedaction < ActiveRecord::Migration
-  def up
+  def change
     add_column :redactions, :user_id, :bigint, :null => false
     add_column :redactions, :description_format, :format_enum, :null => false, :default => "markdown"
 
     add_column :redactions, :user_id, :bigint, :null => false
     add_column :redactions, :description_format, :format_enum, :null => false, :default => "markdown"
 
-    add_foreign_key :redactions, [:user_id], :users, [:id]
-  end
-
-  def down
-    remove_foreign_key :redactions, [:user_id], :users, [:id]
-
-    remove_column :redactions, :description_format
-    remove_column :redactions, :user_id
+    add_foreign_key :redactions, :users, :name => "redactions_user_id_fkey"
   end
 end
   end
 end
index e4337459523db360c366bb94f7929f04d6417261..e0d22306085ef318639df59e1499e85342ca20e6 100644 (file)
@@ -2,7 +2,7 @@ require 'migrate'
 
 class AddTextIndexToNoteComments < ActiveRecord::Migration
   def up
 
 class AddTextIndexToNoteComments < ActiveRecord::Migration
   def up
-    add_index :note_comments, [], :columns => "to_tsvector('english', body)", :method => "GIN", :name => "index_note_comments_on_body"
+    add_index :note_comments, [], :columns => "to_tsvector('english', body)", :using => "GIN", :name => "index_note_comments_on_body"
   end
 
   def down
   end
 
   def down
index 8d2a4599dfd938dfed479f6a77395ddd505f1683..cfc499535c2ed44f5648d8dd86d52d1f8af123d1 100644 (file)
@@ -10,8 +10,8 @@ class CreateChangesetComments < ActiveRecord::Migration
       t.boolean :visible, :null => false
     end
 
       t.boolean :visible, :null => false
     end
 
-    add_foreign_key :changeset_comments, [:changeset_id], :changesets, [:id]
-    add_foreign_key :changeset_comments, [:author_id], :users, [:id]
+    add_foreign_key :changeset_comments, :changesets, :name => "changeset_comments_changeset_id_fkey"
+    add_foreign_key :changeset_comments, :users, :column => :author_id, :name => "changeset_comments_author_id_fkey"
 
     add_index :changeset_comments, :created_at
   end
 
     add_index :changeset_comments, :created_at
   end
index d07c6aae97920fde0fabe512a66bd05d66bc3f07..c23ed1f9f7ca22e1915030ef9129cd3c505259a5 100644 (file)
@@ -7,8 +7,8 @@ class AddJoinTableBetweenUsersAndChangesets < ActiveRecord::Migration
       t.column :changeset_id, :bigint, null: false
     end
 
       t.column :changeset_id, :bigint, null: false
     end
 
-    add_foreign_key :changesets_subscribers, [:subscriber_id], :users, [:id]
-    add_foreign_key :changesets_subscribers, [:changeset_id], :changesets, [:id]
+    add_foreign_key :changesets_subscribers, :users, :column => :subscriber_id, :name => "changesets_subscribers_subscriber_id_fkey"
+    add_foreign_key :changesets_subscribers, :changesets, :name => "changesets_subscribers_changeset_id_fkey"
 
     add_index :changesets_subscribers, [:subscriber_id, :changeset_id], :unique => true
     add_index :changesets_subscribers, [:changeset_id]
 
     add_index :changesets_subscribers, [:subscriber_id, :changeset_id], :unique => true
     add_index :changesets_subscribers, [:changeset_id]
index 343aec084abbc9b1ac43026e1839ca5c41c5647b..cfbd368fda38685759cd9ee9bc2cbf21d3a2b986 100644 (file)
@@ -126,7 +126,7 @@ CREATE TYPE user_status_enum AS ENUM (
 
 CREATE FUNCTION maptile_for_point(bigint, bigint, integer) RETURNS integer
     LANGUAGE c STRICT
 
 CREATE FUNCTION maptile_for_point(bigint, bigint, integer) RETURNS integer
     LANGUAGE c STRICT
-    AS '/srv/www/overpass.osm.compton.nu/db/functions/libpgosm.so', 'maptile_for_point';
+    AS '/srv/www/master.osm.compton.nu/db/functions/libpgosm.so', 'maptile_for_point';
 
 
 --
 
 
 --
@@ -135,7 +135,7 @@ CREATE FUNCTION maptile_for_point(bigint, bigint, integer) RETURNS integer
 
 CREATE FUNCTION tile_for_point(integer, integer) RETURNS bigint
     LANGUAGE c STRICT
 
 CREATE FUNCTION tile_for_point(integer, integer) RETURNS bigint
     LANGUAGE c STRICT
-    AS '/srv/www/overpass.osm.compton.nu/db/functions/libpgosm.so', 'tile_for_point';
+    AS '/srv/www/master.osm.compton.nu/db/functions/libpgosm.so', 'tile_for_point';
 
 
 --
 
 
 --
@@ -144,7 +144,7 @@ CREATE FUNCTION tile_for_point(integer, integer) RETURNS bigint
 
 CREATE FUNCTION xid_to_int4(xid) RETURNS integer
     LANGUAGE c IMMUTABLE STRICT
 
 CREATE FUNCTION xid_to_int4(xid) RETURNS integer
     LANGUAGE c IMMUTABLE STRICT
-    AS '/srv/www/overpass.osm.compton.nu/db/functions/libpgosm.so', 'xid_to_int4';
+    AS '/srv/www/master.osm.compton.nu/db/functions/libpgosm.so', 'xid_to_int4';
 
 
 SET default_tablespace = '';
 
 
 SET default_tablespace = '';
@@ -158,9 +158,9 @@ SET default_with_oids = false;
 CREATE TABLE acls (
     id integer NOT NULL,
     address inet,
 CREATE TABLE acls (
     id integer NOT NULL,
     address inet,
-    k character varying(255) NOT NULL,
-    v character varying(255),
-    domain character varying(255)
+    k character varying NOT NULL,
+    v character varying,
+    domain character varying
 );
 
 
 );
 
 
@@ -222,8 +222,8 @@ ALTER SEQUENCE changeset_comments_id_seq OWNED BY changeset_comments.id;
 
 CREATE TABLE changeset_tags (
     changeset_id bigint NOT NULL,
 
 CREATE TABLE changeset_tags (
     changeset_id bigint NOT NULL,
-    k character varying(255) DEFAULT ''::character varying NOT NULL,
-    v character varying(255) DEFAULT ''::character varying NOT NULL
+    k character varying DEFAULT ''::character varying NOT NULL,
+    v character varying DEFAULT ''::character varying NOT NULL
 );
 
 
 );
 
 
@@ -279,10 +279,10 @@ CREATE TABLE changesets_subscribers (
 
 CREATE TABLE client_applications (
     id integer NOT NULL,
 
 CREATE TABLE client_applications (
     id integer NOT NULL,
-    name character varying(255),
-    url character varying(255),
-    support_url character varying(255),
-    callback_url character varying(255),
+    name character varying,
+    url character varying,
+    support_url character varying,
+    callback_url character varying,
     key character varying(50),
     secret character varying(50),
     user_id integer,
     key character varying(50),
     secret character varying(50),
     user_id integer,
@@ -323,8 +323,8 @@ ALTER SEQUENCE client_applications_id_seq OWNED BY client_applications.id;
 
 CREATE TABLE current_node_tags (
     node_id bigint NOT NULL,
 
 CREATE TABLE current_node_tags (
     node_id bigint NOT NULL,
-    k character varying(255) DEFAULT ''::character varying NOT NULL,
-    v character varying(255) DEFAULT ''::character varying NOT NULL
+    k character varying DEFAULT ''::character varying NOT NULL,
+    v character varying DEFAULT ''::character varying NOT NULL
 );
 
 
 );
 
 
@@ -371,7 +371,7 @@ CREATE TABLE current_relation_members (
     relation_id bigint NOT NULL,
     member_type nwr_enum NOT NULL,
     member_id bigint NOT NULL,
     relation_id bigint NOT NULL,
     member_type nwr_enum NOT NULL,
     member_id bigint NOT NULL,
-    member_role character varying(255) NOT NULL,
+    member_role character varying NOT NULL,
     sequence_id integer DEFAULT 0 NOT NULL
 );
 
     sequence_id integer DEFAULT 0 NOT NULL
 );
 
@@ -382,8 +382,8 @@ CREATE TABLE current_relation_members (
 
 CREATE TABLE current_relation_tags (
     relation_id bigint NOT NULL,
 
 CREATE TABLE current_relation_tags (
     relation_id bigint NOT NULL,
-    k character varying(255) DEFAULT ''::character varying NOT NULL,
-    v character varying(255) DEFAULT ''::character varying NOT NULL
+    k character varying DEFAULT ''::character varying NOT NULL,
+    v character varying DEFAULT ''::character varying NOT NULL
 );
 
 
 );
 
 
@@ -436,8 +436,8 @@ CREATE TABLE current_way_nodes (
 
 CREATE TABLE current_way_tags (
     way_id bigint NOT NULL,
 
 CREATE TABLE current_way_tags (
     way_id bigint NOT NULL,
-    k character varying(255) DEFAULT ''::character varying NOT NULL,
-    v character varying(255) DEFAULT ''::character varying NOT NULL
+    k character varying DEFAULT ''::character varying NOT NULL,
+    v character varying DEFAULT ''::character varying NOT NULL
 );
 
 
 );
 
 
@@ -515,13 +515,13 @@ ALTER SEQUENCE diary_comments_id_seq OWNED BY diary_comments.id;
 CREATE TABLE diary_entries (
     id bigint NOT NULL,
     user_id bigint NOT NULL,
 CREATE TABLE diary_entries (
     id bigint NOT NULL,
     user_id bigint NOT NULL,
-    title character varying(255) NOT NULL,
+    title character varying NOT NULL,
     body text NOT NULL,
     created_at timestamp without time zone NOT NULL,
     updated_at timestamp without time zone NOT NULL,
     latitude double precision,
     longitude double precision,
     body text NOT NULL,
     created_at timestamp without time zone NOT NULL,
     updated_at timestamp without time zone NOT NULL,
     latitude double precision,
     longitude double precision,
-    language_code character varying(255) DEFAULT 'en'::character varying NOT NULL,
+    language_code character varying DEFAULT 'en'::character varying NOT NULL,
     visible boolean DEFAULT true NOT NULL,
     body_format format_enum DEFAULT 'html'::format_enum NOT NULL
 );
     visible boolean DEFAULT true NOT NULL,
     body_format format_enum DEFAULT 'html'::format_enum NOT NULL
 );
@@ -597,7 +597,7 @@ CREATE TABLE gps_points (
 
 CREATE TABLE gpx_file_tags (
     gpx_id bigint DEFAULT 0 NOT NULL,
 
 CREATE TABLE gpx_file_tags (
     gpx_id bigint DEFAULT 0 NOT NULL,
-    tag character varying(255) NOT NULL,
+    tag character varying NOT NULL,
     id bigint NOT NULL
 );
 
     id bigint NOT NULL
 );
 
@@ -629,12 +629,12 @@ CREATE TABLE gpx_files (
     id bigint NOT NULL,
     user_id bigint NOT NULL,
     visible boolean DEFAULT true NOT NULL,
     id bigint NOT NULL,
     user_id bigint NOT NULL,
     visible boolean DEFAULT true NOT NULL,
-    name character varying(255) DEFAULT ''::character varying NOT NULL,
+    name character varying DEFAULT ''::character varying NOT NULL,
     size bigint,
     latitude double precision,
     longitude double precision,
     "timestamp" timestamp without time zone NOT NULL,
     size bigint,
     latitude double precision,
     longitude double precision,
     "timestamp" timestamp without time zone NOT NULL,
-    description character varying(255) DEFAULT ''::character varying NOT NULL,
+    description character varying DEFAULT ''::character varying NOT NULL,
     inserted boolean NOT NULL,
     visibility gpx_visibility_enum DEFAULT 'public'::gpx_visibility_enum NOT NULL
 );
     inserted boolean NOT NULL,
     visibility gpx_visibility_enum DEFAULT 'public'::gpx_visibility_enum NOT NULL
 );
@@ -664,9 +664,9 @@ ALTER SEQUENCE gpx_files_id_seq OWNED BY gpx_files.id;
 --
 
 CREATE TABLE languages (
 --
 
 CREATE TABLE languages (
-    code character varying(255) NOT NULL,
-    english_name character varying(255) NOT NULL,
-    native_name character varying(255)
+    code character varying NOT NULL,
+    english_name character varying NOT NULL,
+    native_name character varying
 );
 
 
 );
 
 
@@ -677,7 +677,7 @@ CREATE TABLE languages (
 CREATE TABLE messages (
     id bigint NOT NULL,
     from_user_id bigint NOT NULL,
 CREATE TABLE messages (
     id bigint NOT NULL,
     from_user_id bigint NOT NULL,
-    title character varying(255) NOT NULL,
+    title character varying NOT NULL,
     body text NOT NULL,
     sent_on timestamp without time zone NOT NULL,
     message_read boolean DEFAULT false NOT NULL,
     body text NOT NULL,
     sent_on timestamp without time zone NOT NULL,
     message_read boolean DEFAULT false NOT NULL,
@@ -714,8 +714,8 @@ ALTER SEQUENCE messages_id_seq OWNED BY messages.id;
 CREATE TABLE node_tags (
     node_id bigint NOT NULL,
     version bigint NOT NULL,
 CREATE TABLE node_tags (
     node_id bigint NOT NULL,
     version bigint NOT NULL,
-    k character varying(255) DEFAULT ''::character varying NOT NULL,
-    v character varying(255) DEFAULT ''::character varying NOT NULL
+    k character varying DEFAULT ''::character varying NOT NULL,
+    v character varying DEFAULT ''::character varying NOT NULL
 );
 
 
 );
 
 
@@ -812,7 +812,7 @@ ALTER SEQUENCE notes_id_seq OWNED BY notes.id;
 
 CREATE TABLE oauth_nonces (
     id integer NOT NULL,
 
 CREATE TABLE oauth_nonces (
     id integer NOT NULL,
-    nonce character varying(255),
+    nonce character varying,
     "timestamp" integer,
     created_at timestamp without time zone,
     updated_at timestamp without time zone
     "timestamp" integer,
     created_at timestamp without time zone,
     updated_at timestamp without time zone
@@ -859,9 +859,9 @@ CREATE TABLE oauth_tokens (
     allow_write_api boolean DEFAULT false NOT NULL,
     allow_read_gpx boolean DEFAULT false NOT NULL,
     allow_write_gpx boolean DEFAULT false NOT NULL,
     allow_write_api boolean DEFAULT false NOT NULL,
     allow_read_gpx boolean DEFAULT false NOT NULL,
     allow_write_gpx boolean DEFAULT false NOT NULL,
-    callback_url character varying(255),
+    callback_url character varying,
     verifier character varying(20),
     verifier character varying(20),
-    scope character varying(255),
+    scope character varying,
     valid_to timestamp without time zone,
     allow_write_notes boolean DEFAULT false NOT NULL
 );
     valid_to timestamp without time zone,
     allow_write_notes boolean DEFAULT false NOT NULL
 );
@@ -892,7 +892,7 @@ ALTER SEQUENCE oauth_tokens_id_seq OWNED BY oauth_tokens.id;
 
 CREATE TABLE redactions (
     id integer NOT NULL,
 
 CREATE TABLE redactions (
     id integer NOT NULL,
-    title character varying(255),
+    title character varying,
     description text,
     created_at timestamp without time zone,
     updated_at timestamp without time zone,
     description text,
     created_at timestamp without time zone,
     updated_at timestamp without time zone,
@@ -928,7 +928,7 @@ CREATE TABLE relation_members (
     relation_id bigint DEFAULT 0 NOT NULL,
     member_type nwr_enum NOT NULL,
     member_id bigint NOT NULL,
     relation_id bigint DEFAULT 0 NOT NULL,
     member_type nwr_enum NOT NULL,
     member_id bigint NOT NULL,
-    member_role character varying(255) NOT NULL,
+    member_role character varying NOT NULL,
     version bigint DEFAULT 0 NOT NULL,
     sequence_id integer DEFAULT 0 NOT NULL
 );
     version bigint DEFAULT 0 NOT NULL,
     sequence_id integer DEFAULT 0 NOT NULL
 );
@@ -940,8 +940,8 @@ CREATE TABLE relation_members (
 
 CREATE TABLE relation_tags (
     relation_id bigint DEFAULT 0 NOT NULL,
 
 CREATE TABLE relation_tags (
     relation_id bigint DEFAULT 0 NOT NULL,
-    k character varying(255) DEFAULT ''::character varying NOT NULL,
-    v character varying(255) DEFAULT ''::character varying NOT NULL,
+    k character varying DEFAULT ''::character varying NOT NULL,
+    v character varying DEFAULT ''::character varying NOT NULL,
     version bigint NOT NULL
 );
 
     version bigint NOT NULL
 );
 
@@ -965,7 +965,7 @@ CREATE TABLE relations (
 --
 
 CREATE TABLE schema_migrations (
 --
 
 CREATE TABLE schema_migrations (
-    version character varying(255) NOT NULL
+    version character varying NOT NULL
 );
 
 
 );
 
 
@@ -1012,8 +1012,8 @@ ALTER SEQUENCE user_blocks_id_seq OWNED BY user_blocks.id;
 
 CREATE TABLE user_preferences (
     user_id bigint NOT NULL,
 
 CREATE TABLE user_preferences (
     user_id bigint NOT NULL,
-    k character varying(255) NOT NULL,
-    v character varying(255) NOT NULL
+    k character varying NOT NULL,
+    v character varying NOT NULL
 );
 
 
 );
 
 
@@ -1024,9 +1024,9 @@ CREATE TABLE user_preferences (
 CREATE TABLE user_roles (
     id integer NOT NULL,
     user_id bigint NOT NULL,
 CREATE TABLE user_roles (
     id integer NOT NULL,
     user_id bigint NOT NULL,
+    role user_role_enum NOT NULL,
     created_at timestamp without time zone,
     updated_at timestamp without time zone,
     created_at timestamp without time zone,
     updated_at timestamp without time zone,
-    role user_role_enum NOT NULL,
     granter_id bigint NOT NULL
 );
 
     granter_id bigint NOT NULL
 );
 
@@ -1057,7 +1057,7 @@ ALTER SEQUENCE user_roles_id_seq OWNED BY user_roles.id;
 CREATE TABLE user_tokens (
     id bigint NOT NULL,
     user_id bigint NOT NULL,
 CREATE TABLE user_tokens (
     id bigint NOT NULL,
     user_id bigint NOT NULL,
-    token character varying(255) NOT NULL,
+    token character varying NOT NULL,
     expiry timestamp without time zone NOT NULL,
     referer text
 );
     expiry timestamp without time zone NOT NULL,
     referer text
 );
@@ -1087,36 +1087,36 @@ ALTER SEQUENCE user_tokens_id_seq OWNED BY user_tokens.id;
 --
 
 CREATE TABLE users (
 --
 
 CREATE TABLE users (
-    email character varying(255) NOT NULL,
+    email character varying NOT NULL,
     id bigint NOT NULL,
     id bigint NOT NULL,
-    pass_crypt character varying(255) NOT NULL,
+    pass_crypt character varying NOT NULL,
     creation_time timestamp without time zone NOT NULL,
     creation_time timestamp without time zone NOT NULL,
-    display_name character varying(255) DEFAULT ''::character varying NOT NULL,
+    display_name character varying DEFAULT ''::character varying NOT NULL,
     data_public boolean DEFAULT false NOT NULL,
     description text DEFAULT ''::text NOT NULL,
     home_lat double precision,
     home_lon double precision,
     home_zoom smallint DEFAULT 3,
     nearby integer DEFAULT 50,
     data_public boolean DEFAULT false NOT NULL,
     description text DEFAULT ''::text NOT NULL,
     home_lat double precision,
     home_lon double precision,
     home_zoom smallint DEFAULT 3,
     nearby integer DEFAULT 50,
-    pass_salt character varying(255),
+    pass_salt character varying,
     image_file_name text,
     email_valid boolean DEFAULT false NOT NULL,
     image_file_name text,
     email_valid boolean DEFAULT false NOT NULL,
-    new_email character varying(255),
-    creation_ip character varying(255),
-    languages character varying(255),
+    new_email character varying,
+    creation_ip character varying,
+    languages character varying,
     status user_status_enum DEFAULT 'pending'::user_status_enum NOT NULL,
     terms_agreed timestamp without time zone,
     consider_pd boolean DEFAULT false NOT NULL,
     status user_status_enum DEFAULT 'pending'::user_status_enum NOT NULL,
     terms_agreed timestamp without time zone,
     consider_pd boolean DEFAULT false NOT NULL,
-    openid_url character varying(255),
-    preferred_editor character varying(255),
+    openid_url character varying,
+    preferred_editor character varying,
     terms_seen boolean DEFAULT false NOT NULL,
     description_format format_enum DEFAULT 'html'::format_enum NOT NULL,
     terms_seen boolean DEFAULT false NOT NULL,
     description_format format_enum DEFAULT 'html'::format_enum NOT NULL,
-    image_fingerprint character varying(255),
+    image_fingerprint character varying,
     changesets_count integer DEFAULT 0 NOT NULL,
     traces_count integer DEFAULT 0 NOT NULL,
     diary_entries_count integer DEFAULT 0 NOT NULL,
     image_use_gravatar boolean DEFAULT true NOT NULL,
     changesets_count integer DEFAULT 0 NOT NULL,
     traces_count integer DEFAULT 0 NOT NULL,
     diary_entries_count integer DEFAULT 0 NOT NULL,
     image_use_gravatar boolean DEFAULT true NOT NULL,
-    image_content_type character varying(255)
+    image_content_type character varying
 );
 
 
 );
 
 
@@ -1157,8 +1157,8 @@ CREATE TABLE way_nodes (
 
 CREATE TABLE way_tags (
     way_id bigint DEFAULT 0 NOT NULL,
 
 CREATE TABLE way_tags (
     way_id bigint DEFAULT 0 NOT NULL,
-    k character varying(255) NOT NULL,
-    v character varying(255) NOT NULL,
+    k character varying NOT NULL,
+    v character varying NOT NULL,
     version bigint NOT NULL
 );
 
     version bigint NOT NULL
 );
 
index 7f8d33693d921eb746660fbe0642bd3026268089..681eba5b603ab7a61012e66759fde1f7a49361a1 100644 (file)
 module ActiveRecord
   module ConnectionAdapters
 module ActiveRecord
   module ConnectionAdapters
-    class PostgreSQLAdapter
-      class SchemaCreation
-        alias_method :old_add_column_options!, :add_column_options!
+    module SchemaStatements
+      def add_index_options_with_columns(table_name, column_name, options = {})
+        columns = options.delete(:columns)
+        index_name, index_type, index_columns, index_options, algorithm, using = add_index_options_without_columns(table_name, column_name, options)
+        [index_name, index_type, columns || index_columns, index_options, algorithm, using]
+      end
+
+      alias_method_chain :add_index_options, :columns
+    end
 
 
-        def add_column_options!(sql, options)
-          sql << " UNSIGNED" if options[:unsigned]
-          old_add_column_options!(sql, options)
-          sql << " #{options[:options]}"
+    module PostgreSQL
+      module Quoting
+        def quote_column_name_with_arrays(name)
+          Array(name).map { |n| quote_column_name_without_arrays(n) }.join(", ")
         end
         end
+
+        alias_method_chain :quote_column_name, :arrays
       end
 
       module SchemaStatements
       end
 
       module SchemaStatements
-        def quote_column_names(column_name)
-          Array(column_name).map { |e| quote_column_name(e) }.join(", ")
-        end
-
         def add_primary_key(table_name, column_name, options = {})
         def add_primary_key(table_name, column_name, options = {})
-          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 (#{quoted_column_names})"
+          execute "ALTER TABLE #{quote_table_name(table_name)} ADD PRIMARY KEY (#{quote_column_name(column_name)})"
         end
 
         def remove_primary_key(table_name)
         end
 
         def remove_primary_key(table_name)
-          execute "ALTER TABLE #{table_name} DROP PRIMARY KEY"
+          execute "ALTER TABLE #{quote_table_name(table_name)} DROP PRIMARY KEY"
         end
 
         end
 
-        def add_foreign_key(table_name, column_name, reftbl, refcol = nil)
-          execute "ALTER TABLE #{table_name} ADD " +
-            "FOREIGN KEY (#{quote_column_names(column_name)}) " +
-            "REFERENCES #{reftbl} (#{quote_column_names(refcol || column_name)})"
+        def alter_primary_key(table_name, new_columns)
+          execute "ALTER TABLE #{quote_table_name(table_name)} DROP CONSTRAINT #{quote_table_name(table_name + "_pkey")}"
+          execute "ALTER TABLE #{quote_table_name(table_name)} ADD PRIMARY KEY (#{quote_column_name(new_columns)})"
         end
 
         end
 
-        def remove_foreign_key(table_name, column_name, reftbl, refcol = nil)
-          execute "ALTER TABLE #{table_name} DROP " +
-            "CONSTRAINT #{table_name}_#{column_name[0]}_fkey"
+        def create_enumeration(enumeration_name, values)
+          execute "CREATE TYPE #{enumeration_name} AS ENUM ('#{values.join '\',\''}')"
         end
 
         end
 
-#        alias_method :old_options_include_default?, :options_include_default?
-#
-#        def options_include_default?(options)
-#          return false if options[:options] =~ /AUTO_INCREMENT/i
-#          return old_options_include_default?(options)
-#        end
-      end
-
-      alias_method :old_native_database_types, :native_database_types
-
-      def native_database_types
-        types = old_native_database_types
-        types[:double] = { :name => "double precision" }
-        types[:integer_pk] = { :name => "serial PRIMARY KEY" }
-        types[:bigint_pk] = { :name => "bigserial PRIMARY KEY" }
-        types[:bigint_pk_64] = { :name => "bigserial PRIMARY KEY" }
-        types[:bigint_auto_64] = { :name => "bigint" } #fixme: need autoincrement?
-        types[:bigint_auto_11] = { :name => "bigint" } #fixme: need autoincrement?
-        types[:bigint_auto_20] = { :name => "bigint" } #fixme: need autoincrement?
-        types[:four_byte_unsigned] = { :name => "bigint" } # meh
-        types[:inet] = { :name=> "inet" }
-
-        enumerations.each_key do |e|
-          types[e.to_sym]= { :name => e }
+        def drop_enumeration(enumeration_name)
+          execute "DROP TYPE #{enumeration_name}"
         end
 
         end
 
-        types
-      end
-
-      def myisam_table
-        return { :id => false, :force => true, :options => ""}
-      end
-
-      def innodb_table
-        return { :id => false, :force => true, :options => ""}
-      end
-
-      def innodb_option
-        return ""
-      end
-
-      def change_engine (table_name, engine)
-      end
-
-      def add_fulltext_index (table_name, column)
-        execute "CREATE INDEX #{table_name}_#{column}_idx on #{table_name} (#{column})"
-      end
-
-      def enumerations
-        @enumerations ||= Hash.new
-      end
-
-      def create_enumeration(enumeration_name, values)
-        enumerations[enumeration_name] = values
-        execute "CREATE TYPE #{enumeration_name} AS ENUM ('#{values.join '\',\''}')"
-      end
-
-      def drop_enumeration(enumeration_name)
-        execute "DROP TYPE #{enumeration_name}"
-        enumerations.delete(enumeration_name)
-      end
-
-      def rename_enumeration(old_name, new_name)
-        execute "ALTER TYPE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}"
-      end
-
-      def alter_primary_key(table_name, new_columns)
-        execute "ALTER TABLE #{table_name} DROP CONSTRAINT #{table_name}_pkey"
-        execute "ALTER TABLE #{table_name} ADD PRIMARY KEY (#{new_columns.join(',')})"
-      end
-
-      def interval_constant(interval)
-        "'#{interval}'::interval"
-      end
-
-      def add_index(table_name, column_name, options = {})
-        column_names = Array(column_name)
-        index_name   = index_name(table_name, :column => column_names)
-
-        if Hash === options # legacy support, since this param was a string
-          index_type = options[:unique] ? "UNIQUE" : ""
-          index_name = options[:name] || index_name
-          index_method = options[:method] || "BTREE"
-        else
-          index_type = options
-        end
-
-        quoted_column_names = column_names.map { |e| quote_column_name(e) }
-        if Hash === options and options[:lowercase]
-          quoted_column_names = quoted_column_names.map { |e| "LOWER(#{e})" }
-        end
-        if Hash === options and options[:columns]
-          quoted_column_names = quoted_column_names + Array[options[:columns]]
+        def rename_enumeration(old_name, new_name)
+          execute "ALTER TYPE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}"
         end
         end
-        quoted_column_names = quoted_column_names.join(", ")
-
-        execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} USING #{index_method} (#{quoted_column_names})"
-      end
-
-      def rename_index(table_name, old_name, new_name)
-        execute "ALTER INDEX #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}"
       end
     end
   end
       end
     end
   end