From ba0977d3755ada267f60b1f0a3299e267f013ddd Mon Sep 17 00:00:00 2001 From: Radhika Chippada Date: Thu, 11 Dec 2014 22:49:31 -0500 Subject: [PATCH] 4523: update db migration script for owner_uuid index to drop index only when it exists. --- .../api/db/migrate/20141208164553_owner_uuid_index.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/api/db/migrate/20141208164553_owner_uuid_index.rb b/services/api/db/migrate/20141208164553_owner_uuid_index.rb index 35358a0736..e7e38b0716 100644 --- a/services/api/db/migrate/20141208164553_owner_uuid_index.rb +++ b/services/api/db/migrate/20141208164553_owner_uuid_index.rb @@ -14,7 +14,13 @@ class OwnerUuidIndex < ActiveRecord::Migration def down tables_with_owner_uuid.each do |table| - remove_index table.to_sym, :owner_uuid + indexes = ActiveRecord::Base.connection.indexes(table) + owner_uuid_index = indexes.select do |index| + index.columns == ['owner_uuid'] + end + if !owner_uuid_index.empty? + remove_index table.to_sym, :owner_uuid + end end end end -- 2.30.2