1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 class RenameReplicationAttributes < ActiveRecord::Migration[4.2]
6 RENAME = [[:redundancy, :replication_desired],
7 [:redundancy_confirmed_as, :replication_confirmed],
8 [:redundancy_confirmed_at, :replication_confirmed_at]]
11 RENAME.each do |oldname, newname|
12 rename_column :collections, oldname, newname
14 remove_column :collections, :redundancy_confirmed_by_client_uuid
15 Collection.reset_column_information
17 # Removing that column dropped some search indexes. Let's put them back.
18 add_index :collections, ["owner_uuid", "modified_by_client_uuid", "modified_by_user_uuid", "portable_data_hash", "uuid", "name", "file_names"], name: 'collections_search_index'
19 execute "CREATE INDEX collections_full_text_search_idx ON collections USING gin(#{Collection.full_text_tsvector});"
23 remove_index :collections, name: 'collections_search_index'
24 add_column :collections, :redundancy_confirmed_by_client_uuid, :string
25 RENAME.reverse.each do |oldname, newname|
26 rename_column :collections, newname, oldname
28 remove_index :collections, :name => 'collections_full_text_search_idx'
29 Collection.reset_column_information
31 execute "CREATE INDEX collections_full_text_search_idx ON collections USING gin(#{Collection.full_text_tsvector});"
32 add_index :collections, ["owner_uuid", "modified_by_client_uuid", "modified_by_user_uuid", "portable_data_hash", "uuid", "name", "file_names", "redundancy_confirmed_by_client_uuid"], name: 'collections_search_index'