summaryrefslogtreecommitdiff
path: root/db/post_migrate/20200203104214_services_remove_temporary_index_on_project_id.rb
blob: c9566d0256c80e135292bc5c0d373b824661eb16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class ServicesRemoveTemporaryIndexOnProjectId < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  INDEX_NAME = 'tmp_index_on_project_id_partial_with_prometheus_services'
  PARTIAL_FILTER = "type = 'PrometheusService'"

  disable_ddl_transaction!

  def up
    remove_concurrent_index :services, :project_id, where: PARTIAL_FILTER, name: INDEX_NAME
  end

  def down
    add_concurrent_index :services, :project_id, where: PARTIAL_FILTER, name: INDEX_NAME
  end
end