12414: Enhance sweep process test to ensure no unwanted deletions happen
[arvados.git] / services / api / db / migrate / 20170706141334_json_collection_properties.rb
1 require './db/migrate/20161213172944_full_text_search_indexes'
2
3 class JsonCollectionProperties < ActiveRecord::Migration
4   def up
5     # Drop the FT index before changing column type to avoid
6     # "PG::DatatypeMismatch: ERROR: COALESCE types jsonb and text
7     # cannot be matched".
8     ActiveRecord::Base.connection.execute 'DROP INDEX IF EXISTS collections_full_text_search_idx'
9     ActiveRecord::Base.connection.execute 'ALTER TABLE collections ALTER COLUMN properties TYPE jsonb USING properties::jsonb'
10     FullTextSearchIndexes.new.replace_index('collections')
11   end
12
13   def down
14     ActiveRecord::Base.connection.execute 'ALTER TABLE collections ALTER COLUMN properties TYPE text'
15   end
16 end