debian-mirror-gitlab/db/migrate/20201021142812_add_index_to_ci_daily_build_group_report_results.rb
2021-01-29 00:20:46 +05:30

25 lines
637 B
Ruby

# 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