diff options
-rw-r--r-- | db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb b/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb index f7fca511e9b..8b2cc40ee59 100644 --- a/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb +++ b/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb @@ -12,7 +12,12 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration end def down - if this_index_exists? && Gitlab::Database.postgresql? + if this_index_exists? + if Gitlab::Database.mysql? && !index_exists?(:ci_variables, :project_id) + # Need to add this index for MySQL project_id foreign key constraint + add_concurrent_index(:ci_variables, :project_id) + end + remove_concurrent_index(:ci_variables, columns, name: index_name) end end @@ -20,7 +25,7 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration private def this_index_exists? - index_exists?(:ci_variables, name: index_name) + index_exists?(:ci_variables, columns, name: index_name) end def columns |