Synchronize indexes (`idx_approval_mr_rules_on_config_id_and_id`, `idx_merge_requests_on_unmerged_state_id`)
Why are we doing this work?
We need to synchronously create the indexes that were scheduled for creation in !143668 (merged).
See: !143668 (comment 1776634559)
Implementation Plan
class AddIndexApprovalMergeRequestRulesOnConfigIdAndIdAndUpdatedAt < Gitlab::Database::Migration[2.2]
milestone '16.10'
disable_ddl_transaction!
INDEX_NAME = :idx_approval_mr_rules_on_config_id_and_id_and_updated_at
TABLE_NAME = :approval_merge_request_rules
def up
add_concurrent_index(TABLE_NAME, %i[security_orchestration_policy_configuration_id id updated_at], name: INDEX_NAME)
end
def down
remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME)
end
end
class AddIndexMergeRequestsOnUnmergedStateId < Gitlab::Database::Migration[2.2]
milestone '16.10'
disable_ddl_transaction!
INDEX_NAME = :idx_merge_requests_on_unmerged_state_id
TABLE_NAME = :merge_requests
def up
add_concurrent_index(TABLE_NAME, :id, name: INDEX_NAME, where: "state_id <> 3")
end
def down
remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME)
end
end
class RemoveIndexApprovalMergeRequestRulesOnSecOrchestrationConfigId < Gitlab::Database::Migration[2.2]
milestone '16.10'
disable_ddl_transaction!
TABLE_NAME = :approval_merge_request_rules
INDEX_NAME = :idx_approval_merge_request_rules_on_sec_orchestration_config_id
def up
remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME)
end
def down
add_concurrent_index(TABLE_NAME, :security_orchestration_policy_configuration_id, name: INDEX_NAME)
end
end
Edited by Dominic Bauer