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

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

class UpdateIndexVulnerabilitiesProjectIdId < Gitlab::Database::Migration[2.0]
  disable_ddl_transaction!

  NEW_INDEX_NAME = 'index_vulnerabilities_project_id_and_id_on_default_branch'
  OLD_INDEX_NAME = 'index_vulnerabilities_on_project_id_and_id'

  def up
    add_concurrent_index :vulnerabilities, [:project_id, :id],
                         where: 'present_on_default_branch IS TRUE',
                         name: NEW_INDEX_NAME

    remove_concurrent_index_by_name(:vulnerabilities, OLD_INDEX_NAME)
  end

  def down
    add_concurrent_index :vulnerabilities, [:project_id, :id], name: OLD_INDEX_NAME

    remove_concurrent_index_by_name(:vulnerabilities, NEW_INDEX_NAME)
  end
end