Remove index by name on ci_pipelines
What does this MR do?
In some older instances, there's a duplicate index on ci_pipelines.project_id
.
This causes upgrades to >12.7 to fail because the migration introduced in !22325 (merged) fails with:
ArgumentError: Multiple indexes found on ci_pipelines columns [:project_id]. Specify an index name from ci_pipelines_project_id_idx, index_ci_pipelines_on_project_id
This MR updates the migration to remove both indexes explicitly by name.
Related to #36042 (closed)
Closes #215790 (closed)
Testing
╰─>$ RAILS_ENV=test bin/rails dbconsole
gitlabhq_test=# create index index_ci_pipelines_on_project_id on ci_pipelines (project_id);
CREATE INDEX
gitlabhq_test=# create index ci_pipelines_project_id_idx on ci_pipelines (project_id);
CREATE INDEX
╰─>$ RAILS_ENV=test bin/rake db:migrate:up VERSION=20191229140154
== 20191229140154 DropIndexCiPipelinesOnProjectId: migrating ==================
-- transaction_open?()
-> 0.0000s
-- indexes(:ci_pipelines)
-> 0.0055s
-- execute("SET statement_timeout TO 0")
-> 0.0004s
-- remove_index(:ci_pipelines, {:algorithm=>:concurrently, :name=>"index_ci_pipelines_on_project_id"})
-> 0.0018s
-- execute("RESET ALL")
-> 0.0004s
-- transaction_open?()
-> 0.0000s
-- indexes(:ci_pipelines)
-> 0.0033s
-- execute("SET statement_timeout TO 0")
-> 0.0004s
-- remove_index(:ci_pipelines, {:algorithm=>:concurrently, :name=>"ci_pipelines_project_id_idx"})
-> 0.0010s
-- execute("RESET ALL")
-> 0.0003s
== 20191229140154 DropIndexCiPipelinesOnProjectId: migrated (0.0134s) =========
╰─>$ RAILS_ENV=test bin/rake db:migrate:down VERSION=20191229140154
== 20191229140154 DropIndexCiPipelinesOnProjectId: reverting ==================
-- transaction_open?()
-> 0.0000s
-- index_exists?(:ci_pipelines, :project_id, {:name=>"index_ci_pipelines_on_project_id", :algorithm=>:concurrently})
-> 0.0063s
-- execute("SET statement_timeout TO 0")
-> 0.0006s
-- add_index(:ci_pipelines, :project_id, {:name=>"index_ci_pipelines_on_project_id", :algorithm=>:concurrently})
-> 0.0112s
-- execute("RESET ALL")
-> 0.0006s
== 20191229140154 DropIndexCiPipelinesOnProjectId: reverted (0.0190s) =========