move fulltext indexes to monkeypatch, since not all dbs have a fulltext analogue
authorAndy Allan <gravitystorm@gmail.com>
Sat, 8 Nov 2008 18:44:38 +0000 (18:44 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Sat, 8 Nov 2008 18:44:38 +0000 (18:44 +0000)
db/migrate/001_create_osm_db.rb
db/migrate/007_add_relations.rb
lib/migrate.rb

index 998e129..3e33779 100644 (file)
@@ -50,7 +50,7 @@ class CreateOsmDb < ActiveRecord::Migration
     end
 
     add_index "current_way_tags", ["id"], :name => "current_way_tags_id_idx"
-    execute "CREATE FULLTEXT INDEX `current_way_tags_v_idx` ON `current_way_tags` (`v`)"
+    add_fulltext_index "current_way_tags", "v"
 
     create_table "current_ways", myisam_table do |t|
       t.column "id",        :bigint_pk_64, :null => false
index dea777d..b4aff6e 100644 (file)
@@ -24,7 +24,7 @@ class AddRelations < ActiveRecord::Migration
     end
 
     add_index "current_relation_tags", ["id"], :name => "current_relation_tags_id_idx"
-    execute "CREATE FULLTEXT INDEX `current_relation_tags_v_idx` ON `current_relation_tags` (`v`)"
+    add_fulltext_index "current_relation_tags", "v"
 
     create_table "current_relations", innodb_table do |t|
       t.column "id",        :bigint_pk_64,           :null => false
index df7e5f7..585b47b 100644 (file)
@@ -81,6 +81,10 @@ module ActiveRecord
       def change_engine (table_name, engine)
         execute "ALTER TABLE #{table_name} ENGINE = #{engine}"
       end
+
+      def add_fulltext_index (table_name, column)
+        execute "CREATE FULLTEXT INDEX `#{table_name}_#{column}_idx` ON `#{table_name}` (`#{column}`)"
+      end
     end
   end
 end