From 534148e965ae455895d5ef9f7c61df850a377dcf Mon Sep 17 00:00:00 2001
From: Robert Speicher <robert@gitlab.com>
Date: Tue, 22 Mar 2016 02:21:39 +0000
Subject: [PATCH] Merge branch 'issue_12658' into 'master'

Check if index exists before adding it

I got an error when updating GDK because it already exists.

[ci skip]

See merge request !3335
---
 .../20160320204112_index_namespaces_on_visibility_level.rb    | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/db/migrate/20160320204112_index_namespaces_on_visibility_level.rb b/db/migrate/20160320204112_index_namespaces_on_visibility_level.rb
index b3145443497..370b339d45c 100644
--- a/db/migrate/20160320204112_index_namespaces_on_visibility_level.rb
+++ b/db/migrate/20160320204112_index_namespaces_on_visibility_level.rb
@@ -1,5 +1,7 @@
 class IndexNamespacesOnVisibilityLevel < ActiveRecord::Migration
   def change
-    add_index :namespaces, :visibility_level
+    unless index_exists?(:namespaces, :visibility_level)
+      add_index :namespaces, :visibility_level
+    end
   end
 end
-- 
2.30.9