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

20200206135203_udpate_index_ci_builds_on_name_for_security_products.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ddaa30495430d63b632b3d3848c467d75aa7be66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class UdpateIndexCiBuildsOnNameForSecurityProducts < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  INDEX_NAME = 'index_ci_builds_on_name_for_security_products_values'
  INDEX_NAME_NEW = 'index_ci_builds_on_name_for_security_reports_values'
  INITIAL_INDEX = "((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text"

  disable_ddl_transaction!

  def up
    add_concurrent_index(:ci_builds,
                         :name,
                         name: INDEX_NAME_NEW,
                         where: INITIAL_INDEX + ", ('license_scanning'::character varying)::text]))")

    remove_concurrent_index_by_name(:ci_builds, INDEX_NAME)
  end

  def down
    add_concurrent_index(:ci_builds,
                         :name,
                         name: INDEX_NAME,
                         where: INITIAL_INDEX + ']))')

    remove_concurrent_index_by_name(:ci_builds, INDEX_NAME_NEW)
  end
end