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

20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fb3d12840cc78cd09999a128950b94fc1f53688c (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
# frozen_string_literal: true

class RemovePendingBuildsCoveringIndexFromCiBuilds < Gitlab::Database::Migration[2.0]
  disable_ddl_transaction!

  INDEX_NAME = 'index_ci_builds_runner_id_pending_covering'

  def up
    remove_concurrent_index_by_name :ci_builds, INDEX_NAME
  end

  # rubocop:disable Migration/PreventIndexCreation
  def down
    disable_statement_timeout do
      unless index_exists_by_name?(:ci_builds, INDEX_NAME)
        execute <<~SQL.squish
          CREATE INDEX CONCURRENTLY #{INDEX_NAME}
            ON ci_builds (runner_id, id)
            INCLUDE (project_id)
            WHERE status = 'pending' AND type = 'Ci::Build'
        SQL
      end
    end
  end
  # rubocop:enable Migration/PreventIndexCreation
end