Skip to content

Prepare ci_builds swap indexes for async creation

Patrick Bair requested to merge pb-prepare-async-indexes-for-ci-builds into master

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

Availability and Testing

Edited by Patrick Bair

Merge request reports

Loading