1 class CollectionNameOwnerUniqueOnlyNonExpired < ActiveRecord::Migration
3 indexes = ActiveRecord::Base.connection.indexes('collections')
4 name_owner_index = indexes.select do |index|
5 index.name == 'collection_owner_uuid_name_unique'
11 remove_index :collections, :name => 'collection_owner_uuid_name_unique' if !find_index.empty?
12 add_index(:collections, [:owner_uuid, :name], unique: true,
13 where: 'expires_at is null',
14 name: 'collection_owner_uuid_name_unique')
18 # it failed during up. is it going to pass now? should we do nothing?
19 remove_index :collections, :name => 'collection_owner_uuid_name_unique' if !find_index.empty?
20 add_index(:collections, [:owner_uuid, :name], unique: true,
21 name: 'collection_owner_uuid_name_unique')