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

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

class AddTempIndexForProjectStatisticsUpdatedAt < Gitlab::Database::Migration[2.1]
  INDEX_PROJECT_STATISTICS_UPDATED_AT = 'tmp_index_project_statistics_updated_at'

  disable_ddl_transaction!

  def up
    # Temporary index is to be used to trigger a refresh of project_statistics repository_size
    add_concurrent_index :project_statistics, [:project_id, :updated_at],
      name: INDEX_PROJECT_STATISTICS_UPDATED_AT,
      where: "repository_size > 0"
  end

  def down
    remove_concurrent_index_by_name :project_statistics, INDEX_PROJECT_STATISTICS_UPDATED_AT
  end
end