From: Andy Allan Date: Sat, 8 Nov 2008 18:44:38 +0000 (+0000) Subject: move fulltext indexes to monkeypatch, since not all dbs have a fulltext analogue X-Git-Tag: live~8121^2~194 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/550ce43250208b25d459247d3bbb5bbc25fa3ff4?ds=sidebyside move fulltext indexes to monkeypatch, since not all dbs have a fulltext analogue --- diff --git a/db/migrate/001_create_osm_db.rb b/db/migrate/001_create_osm_db.rb index 998e12951..3e3377921 100644 --- a/db/migrate/001_create_osm_db.rb +++ b/db/migrate/001_create_osm_db.rb @@ -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 diff --git a/db/migrate/007_add_relations.rb b/db/migrate/007_add_relations.rb index dea777d5d..b4aff6e09 100644 --- a/db/migrate/007_add_relations.rb +++ b/db/migrate/007_add_relations.rb @@ -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 diff --git a/lib/migrate.rb b/lib/migrate.rb index df7e5f7ae..585b47b1c 100644 --- a/lib/migrate.rb +++ b/lib/migrate.rb @@ -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