Commit 61cace63 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'sh-clean-duplicate-ci-trigger-request-indexes' into 'master'

Clean up duplicate indexes on ci_trigger_requests

Closes #34818

See merge request gitlab-org/gitlab!19053
parents 4dc9b040 bfe38dfe
---
title: Clean up duplicate indexes on ci_trigger_requests
merge_request: 19053
author:
type: fixed
...@@ -10,7 +10,12 @@ class ReplaceCiTriggerRequestsIndex < ActiveRecord::Migration[5.2] ...@@ -10,7 +10,12 @@ class ReplaceCiTriggerRequestsIndex < ActiveRecord::Migration[5.2]
def up def up
add_concurrent_index :ci_trigger_requests, [:trigger_id, :id], order: { id: :desc } add_concurrent_index :ci_trigger_requests, [:trigger_id, :id], order: { id: :desc }
remove_concurrent_index :ci_trigger_requests, [:trigger_id] # Some installations have legacy, duplicate indexes on
# ci_trigger_requests.trigger_id. Rails won't drop them without an
# explicit name: https://gitlab.com/gitlab-org/gitlab/issues/34818
old_index_names.each do |name|
remove_concurrent_index :ci_trigger_requests, [:trigger_id], name: name
end
end end
def down def down
...@@ -18,4 +23,10 @@ class ReplaceCiTriggerRequestsIndex < ActiveRecord::Migration[5.2] ...@@ -18,4 +23,10 @@ class ReplaceCiTriggerRequestsIndex < ActiveRecord::Migration[5.2]
remove_concurrent_index :ci_trigger_requests, [:trigger_id, :id], order: { id: :desc } remove_concurrent_index :ci_trigger_requests, [:trigger_id, :id], order: { id: :desc }
end end
private
def old_index_names
indexes(:ci_trigger_requests).select { |i| i.columns == ['trigger_id'] }.map(&:name)
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment