Prepare ci_builds swap indexes for async creation
What does this MR do?
See #325619 (closed)
Migration up
$ rails db:migrate:up VERSION=20210901184511
== 20210901184511 PrepareAsyncIndexesForCiBuilds: migrating ===================
-- index_exists?(:ci_builds, :stage_id_convert_to_bigint, {:name=>:index_ci_builds_on_converted_stage_id, :algorithm=>:concurrently})
-> 0.0087s
-- add_index_options(:ci_builds, :stage_id_convert_to_bigint, {:name=>:index_ci_builds_on_converted_stage_id, :algorithm=>:concurrently})
-> 0.0000s
-- index_exists?(:ci_builds, [:commit_id, :artifacts_expire_at, :id_convert_to_bigint], {:where=>"type::text = 'Ci::Build'::text\n AND (retried = false OR retried IS NULL)\n AND (name::text = ANY (ARRAY['sast'::character varying::text,\n 'secret_detection'::character varying::text,\n 'dependency_scanning'::character varying::text,\n 'container_scanning'::character varying::text,\n 'dast'::character varying::text]))", :name=>:index_ci_builds_on_commit_id_expire_at_and_converted_id, :algorithm=>:concurrently})
-> 0.0083s
-- add_index_options(:ci_builds, [:commit_id, :artifacts_expire_at, :id_convert_to_bigint], {:where=>"type::text = 'Ci::Build'::text\n AND (retried = false OR retried IS NULL)\n AND (name::text = ANY (ARRAY['sast'::character varying::text,\n 'secret_detection'::character varying::text,\n 'dependency_scanning'::character varying::text,\n 'container_scanning'::character varying::text,\n 'dast'::character varying::text]))", :name=>:index_ci_builds_on_commit_id_expire_at_and_converted_id, :algorithm=>:concurrently})
-> 0.0000s
-- index_exists?(:ci_builds, [:project_id, :id_convert_to_bigint], {:name=>:index_ci_builds_on_project_and_converted_id, :algorithm=>:concurrently})
-> 0.0069s
-- add_index_options(:ci_builds, [:project_id, :id_convert_to_bigint], {:name=>:index_ci_builds_on_project_and_converted_id, :algorithm=>:concurrently})
-> 0.0000s
-- index_exists?(:ci_builds, [:runner_id, :id_convert_to_bigint], {:order=>{:id_convert_to_bigint=>:desc}, :name=>:index_ci_builds_on_runner_id_and_converted_id_desc, :algorithm=>:concurrently})
-> 0.0072s
-- add_index_options(:ci_builds, [:runner_id, :id_convert_to_bigint], {:order=>{:id_convert_to_bigint=>:desc}, :name=>:index_ci_builds_on_runner_id_and_converted_id_desc, :algorithm=>:concurrently})
-> 0.0000s
-- index_exists?(:ci_builds, [:resource_group_id, :id_convert_to_bigint], {:where=>"resource_group_id IS NOT NULL", :name=>:index_ci_builds_on_resource_group_and_converted_id, :algorithm=>:concurrently})
-> 0.0080s
-- add_index_options(:ci_builds, [:resource_group_id, :id_convert_to_bigint], {:where=>"resource_group_id IS NOT NULL", :name=>:index_ci_builds_on_resource_group_and_converted_id, :algorithm=>:concurrently})
-> 0.0000s
-- index_exists?(:ci_builds, [:name, :id_convert_to_bigint], {:where=>"(name::text = ANY (ARRAY['container_scanning'::character varying::text,\n 'dast'::character varying::text,\n 'dependency_scanning'::character varying::text,\n 'license_management'::character varying::text,\n 'sast'::character varying::text,\n 'secret_detection'::character varying::text,\n 'coverage_fuzzing'::character varying::text,\n 'license_scanning'::character varying::text])\n ) AND type::text = 'Ci::Build'::text", :name=>:index_security_ci_builds_on_name_and_converted_id_parser, :algorithm=>:concurrently})
-> 0.0071s
-- add_index_options(:ci_builds, [:name, :id_convert_to_bigint], {:where=>"(name::text = ANY (ARRAY['container_scanning'::character varying::text,\n 'dast'::character varying::text,\n 'dependency_scanning'::character varying::text,\n 'license_management'::character varying::text,\n 'sast'::character varying::text,\n 'secret_detection'::character varying::text,\n 'coverage_fuzzing'::character varying::text,\n 'license_scanning'::character varying::text])\n ) AND type::text = 'Ci::Build'::text", :name=>:index_security_ci_builds_on_name_and_converted_id_parser, :algorithm=>:concurrently})
-> 0.0000s
-- index_name_exists?(:ci_builds, :index_ci_builds_runner_id_and_converted_id_pending_covering)
-> 0.0007s
== 20210901184511 PrepareAsyncIndexesForCiBuilds: migrated (0.0911s) ==========
Migration down
$ rails db:migrate:down VERSION=20210901184511
== 20210901184511 PrepareAsyncIndexesForCiBuilds: reverting ===================
== 20210901184511 PrepareAsyncIndexesForCiBuilds: reverted (0.0215s) ==========
Screenshots or Screencasts (strongly suggested)
How to setup and validate locally (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Edited by Patrick Bair