1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 class CollectionNameOwnerUniqueOnlyNonExpired < ActiveRecord::Migration[4.2]
7 indexes = ActiveRecord::Base.connection.indexes('collections')
8 name_owner_index = indexes.select do |index|
9 index.name == 'collection_owner_uuid_name_unique'
15 remove_index :collections, :name => 'collection_owner_uuid_name_unique' if !find_index.empty?
16 add_index(:collections, [:owner_uuid, :name], unique: true,
17 where: 'expires_at is null',
18 name: 'collection_owner_uuid_name_unique')
22 # it failed during up. is it going to pass now? should we do nothing?
23 remove_index :collections, :name => 'collection_owner_uuid_name_unique' if !find_index.empty?
24 add_index(:collections, [:owner_uuid, :name], unique: true,
25 name: 'collection_owner_uuid_name_unique')