Merge branch 'master' into 11850-singlecontainer-max-requirements
[arvados.git] / services / api / db / migrate / 20170706141334_json_collection_properties.rb
index 35ee7eaf3ac2c977856dcf7a6146f03458550aa5..003e5fb0929edfa490e4be82383f2ca7e0b75acb 100644 (file)
@@ -2,7 +2,10 @@ require './db/migrate/20161213172944_full_text_search_indexes'
 
 class JsonCollectionProperties < ActiveRecord::Migration
   def up
-    ActiveRecord::Base.connection.execute 'DROP INDEX collections_full_text_search_idx'
+    # Drop the FT index before changing column type to avoid
+    # "PG::DatatypeMismatch: ERROR: COALESCE types jsonb and text
+    # cannot be matched".
+    ActiveRecord::Base.connection.execute 'DROP INDEX IF EXISTS collections_full_text_search_idx'
     ActiveRecord::Base.connection.execute 'ALTER TABLE collections ALTER COLUMN properties TYPE jsonb USING properties::jsonb'
     FullTextSearchIndexes.new.replace_index('collections')
   end