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

20230718145613_add_temp_index_for_project_statistics_pipeline_artifacts_size_migration.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 17e1e9e81f823c7c3493532c59b893c06aba3c23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class AddTempIndexForProjectStatisticsPipelineArtifactsSizeMigration < Gitlab::Database::Migration[2.1]
  INDEX_PROJECT_STATSISTICS_PIPELINE_ARTIFACTS_SIZE = 'tmp_index_project_statistics_pipeline_artifacts_size'

  disable_ddl_transaction!

  def up
    # Temporary index is to be used to trigger a refresh of project_statistics with
    # pipeline_artifacts_size != 0
    add_concurrent_index :project_statistics, [:project_id],
      name: INDEX_PROJECT_STATSISTICS_PIPELINE_ARTIFACTS_SIZE,
      where: "pipeline_artifacts_size != 0"
  end

  def down
    remove_concurrent_index_by_name :project_statistics, INDEX_PROJECT_STATSISTICS_PIPELINE_ARTIFACTS_SIZE
  end
end