1 class RenameReplicationAttributes < ActiveRecord::Migration
2 RENAME = [[:redundancy, :replication_desired],
3 [:redundancy_confirmed_as, :replication_confirmed],
4 [:redundancy_confirmed_at, :replication_confirmed_at]]
7 RENAME.each do |oldname, newname|
8 rename_column :collections, oldname, newname
10 remove_column :collections, :redundancy_confirmed_by_client_uuid
11 Collection.reset_column_information
13 # Removing that column dropped some search indexes. Let's put them back.
14 add_index :collections, ["owner_uuid", "modified_by_client_uuid", "modified_by_user_uuid", "portable_data_hash", "uuid", "name", "file_names"], name: 'collections_search_index'
15 execute "CREATE INDEX collections_full_text_search_idx ON collections USING gin(#{Collection.full_text_tsvector});"
19 remove_index :collections, name: 'collections_search_index'
20 add_column :collections, :redundancy_confirmed_by_client_uuid, :string
21 RENAME.reverse.each do |oldname, newname|
22 rename_column :collections, newname, oldname
24 remove_index :collections, :name => 'collections_full_text_search_idx'
25 Collection.reset_column_information
27 execute "CREATE INDEX collections_full_text_search_idx ON collections USING gin(#{Collection.full_text_tsvector});"
28 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'