summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220302203410_create_index_security_ci_builds_on_name_and_id_parser_with_new_features.rb
blob: 5be6bb002693371e4cfa319cef29a02f3e7c3510 (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
# frozen_string_literal: true

class CreateIndexSecurityCiBuildsOnNameAndIdParserWithNewFeatures < Gitlab::Database::Migration[1.0]
  TABLE = "ci_builds"
  COLUMNS = %i[name id]
  INDEX_NAME = "index_security_ci_builds_on_name_and_id_parser_features"
  CONSTRAINTS = "(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,
                                         'secret_detection'::character varying::text,
                                         'coverage_fuzzing'::character varying::text,
                                         'license_scanning'::character varying::text,
                                         'apifuzzer_fuzz'::character varying::text,
                                         'apifuzzer_fuzz_dnd'::character varying::text])
                ) AND type::text = 'Ci::Build'::text"

  disable_ddl_transaction!

  def up
    add_concurrent_index(TABLE, COLUMNS, name: INDEX_NAME, where: CONSTRAINTS)
  end

  def down
    remove_concurrent_index(TABLE, COLUMNS, name: INDEX_NAME, where: CONSTRAINTS)
  end
end