Commit f6c0ef55 authored by Stan Hu's avatar Stan Hu

Conditionally remove indices that may not exist in pre-GitLab v6.7 installations

Closes #1593
parent c4aa7003
...@@ -3,8 +3,15 @@ class AddMissingUniqueIndices < ActiveRecord::Migration ...@@ -3,8 +3,15 @@ class AddMissingUniqueIndices < ActiveRecord::Migration
def self.up def self.up
add_index :tags, :name, unique: true add_index :tags, :name, unique: true
# pre-GitLab v6.7.0 may not have these indices since there were no
# migrations for them
if index_exists?(:taggings, :tag_id)
remove_index :taggings, :tag_id remove_index :taggings, :tag_id
end
if index_exists?(:taggings, [:taggable_id, :taggable_type, :context])
remove_index :taggings, [:taggable_id, :taggable_type, :context] remove_index :taggings, [:taggable_id, :taggable_type, :context]
end
add_index :taggings, add_index :taggings,
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type], [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
unique: true, name: 'taggings_idx' unique: true, name: 'taggings_idx'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment