1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require './db/migrate/20161213172944_full_text_search_indexes'
7 class JsonCollectionProperties < ActiveRecord::Migration[4.2]
9 # Drop the FT index before changing column type to avoid
10 # "PG::DatatypeMismatch: ERROR: COALESCE types jsonb and text
12 ActiveRecord::Base.connection.execute 'DROP INDEX IF EXISTS collections_full_text_search_idx'
13 ActiveRecord::Base.connection.execute 'ALTER TABLE collections ALTER COLUMN properties TYPE jsonb USING properties::jsonb'
14 FullTextSearchIndexes.new.replace_index('collections')
18 ActiveRecord::Base.connection.execute 'ALTER TABLE collections ALTER COLUMN properties TYPE text'