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