diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20200206135203_udpate_index_ci_builds_on_name_for_security_products.rb | 33 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 34 insertions, 1 deletions
diff --git a/db/post_migrate/20200206135203_udpate_index_ci_builds_on_name_for_security_products.rb b/db/post_migrate/20200206135203_udpate_index_ci_builds_on_name_for_security_products.rb new file mode 100644 index 00000000000..ddaa3049543 --- /dev/null +++ b/db/post_migrate/20200206135203_udpate_index_ci_builds_on_name_for_security_products.rb @@ -0,0 +1,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 diff --git a/db/schema.rb b/db/schema.rb index 824554e41bb..8d51dbb43a0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -682,7 +682,7 @@ ActiveRecord::Schema.define(version: 2020_02_07_151640) do t.index ["commit_id", "status", "type"], name: "index_ci_builds_on_commit_id_and_status_and_type" t.index ["commit_id", "type", "name", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_name_and_ref" t.index ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref" - t.index ["name"], name: "index_ci_builds_on_name_for_security_products_values", where: "((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]))" + t.index ["name"], name: "index_ci_builds_on_name_for_security_reports_values", where: "((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, ('license_scanning'::character varying)::text]))" t.index ["project_id", "id"], name: "index_ci_builds_on_project_id_and_id" t.index ["project_id", "name", "ref"], name: "index_ci_builds_on_project_id_and_name_and_ref", where: "(((type)::text = 'Ci::Build'::text) AND ((status)::text = 'success'::text) AND ((retried = false) OR (retried IS NULL)))" t.index ["project_id", "status"], name: "index_ci_builds_project_id_and_status_for_live_jobs_partial2", where: "(((type)::text = 'Ci::Build'::text) AND ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text])))" |