Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20230825085719_create_async_index_for_ci_stages_pipeline_id.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a517d96815aa874242b30dc6ab0838671c14228a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

class CreateAsyncIndexForCiStagesPipelineId < Gitlab::Database::Migration[2.1]
  TABLE_NAME = :ci_stages
  INDEXES = {
    'index_ci_stages_on_pipeline_id_convert_to_bigint_and_name' => [
      [:pipeline_id_convert_to_bigint, :name], { unique: true }
    ],
    'index_ci_stages_on_pipeline_id_convert_to_bigint' => [
      [:pipeline_id_convert_to_bigint], {}
    ],
    'index_ci_stages_on_pipeline_id_convert_to_bigint_and_id' => [
      [:pipeline_id_convert_to_bigint, :id], { where: 'status = ANY (ARRAY[0, 1, 2, 8, 9, 10])' }
    ],
    'index_ci_stages_on_pipeline_id_convert_to_bigint_and_position' => [
      [:pipeline_id_convert_to_bigint, :position], {}
    ]
  }

  def up
    INDEXES.each do |index_name, (columns, options)|
      prepare_async_index TABLE_NAME, columns, name: index_name, **options
    end
  end

  def down
    INDEXES.each do |index_name, (columns, options)|
      unprepare_async_index TABLE_NAME, columns, name: index_name, **options
    end
  end
end