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

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

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

  DOWNTIME = false
  INDEX_NAME = 'index_ci_daily_build_group_report_results_on_project_and_date'

  disable_ddl_transaction!

  def up
    add_concurrent_index(
      :ci_daily_build_group_report_results,
      [:project_id, :date],
      order: { date: :desc },
      where: "default_branch = TRUE AND (data -> 'coverage') IS NOT NULL",
      name: INDEX_NAME
    )
  end

  def down
    remove_concurrent_index_by_name(:ci_daily_build_group_report_results, INDEX_NAME)
  end
end