1 require './db/migrate/20161213172944_full_text_search_indexes'
3 class JsonCollectionProperties < ActiveRecord::Migration
5 # Drop the FT index before changing column type to avoid
6 # "PG::DatatypeMismatch: ERROR: COALESCE types jsonb and text
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')
14 ActiveRecord::Base.connection.execute 'ALTER TABLE collections ALTER COLUMN properties TYPE text'