summaryrefslogtreecommitdiff
path: root/db/migrate/20180306134842_add_missing_indexes_acts_as_taggable_on_engine.rb
blob: 06e402adcd71c223844a9f894c473e8d1af90a57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# This migration comes from acts_as_taggable_on_engine (originally 6)
#
# It has been modified to handle no-downtime GitLab migrations. Several
# indexes have been removed since they are not needed for GitLab.
class AddMissingIndexesActsAsTaggableOnEngine < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_concurrent_index :taggings, :tag_id unless index_exists? :taggings, :tag_id
    add_concurrent_index :taggings, [:taggable_id, :taggable_type] unless index_exists? :taggings, [:taggable_id, :taggable_type]
  end

  def down
    remove_concurrent_index :taggings, :tag_id
    remove_concurrent_index :taggings, [:taggable_id, :taggable_type]
  end
end