1 require "./db/migrate/20150123142953_full_text_search.rb"
3 class LeadingSpaceOnFullTextIndex < ActiveRecord::Migration
5 # Inspect one of the full-text indexes (chosen arbitrarily) to
6 # determine whether this migration is needed.
7 ft_index_name = 'jobs_full_text_search_idx'
8 ActiveRecord::Base.connection.indexes('jobs').each do |idx|
9 if idx.name == ft_index_name
10 if idx.columns.first.index "((((' '"
11 # Index is already correct. This happens if the source tree
12 # already had the new version of full_text_tsvector by the
13 # time the initial FullTextSearch migration ran.
14 $stderr.puts "This migration is not needed."
16 # Index was created using the old full_text_tsvector. Drop
17 # and re-create all full text indexes.
18 FullTextSearch.new.migrate(:down)
19 FullTextSearch.new.migrate(:up)
24 raise "Did not find index '#{ft_index_name}'. Earlier migration missed??"
29 Down-migration is not supported for this change, and might be unnecessary.
31 If you run a code base older than 20150526180251 against this
32 database, full text search will be slow even on collections where it
33 used to work well. If this is a concern, first check out the desired
34 older version of the code base, and then run
35 "rake db:migrate:down VERSION=20150123142953"
37 "rake db:migrate:up VERSION=20150123142953"