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

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

class AddIndexPackagesNpmMetadataCachesOnIdAndProjectIdAndStatus < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!

  INDEX_NAME = 'idx_pkgs_npm_metadata_caches_on_id_and_project_id_and_status'
  NPM_METADATA_CACHES_STATUS_DEFAULT = 0

  def up
    where = "project_id IS NULL AND status = #{NPM_METADATA_CACHES_STATUS_DEFAULT}"

    add_concurrent_index :packages_npm_metadata_caches, :id, name: INDEX_NAME, where: where
  end

  def down
    remove_concurrent_index_by_name :packages_npm_metadata_caches, name: INDEX_NAME
  end
end