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

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

  DOWNTIME = false
  OLD_INDEX_NAME = 'index_ci_pipelines_on_status'
  NEW_INDEX_NAME = 'index_ci_pipelines_on_status_and_id'

  disable_ddl_transaction!

  def up
    add_concurrent_index :ci_pipelines, [:status, :id], name: NEW_INDEX_NAME
    remove_concurrent_index_by_name :ci_pipelines, name: OLD_INDEX_NAME
  end

  def down
    add_concurrent_index :ci_pipelines, :status, name: OLD_INDEX_NAME
    remove_concurrent_index_by_name :ci_pipelines, name: NEW_INDEX_NAME
  end
end