Commit 25b770e4 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Add `rule_type` to indexes explicitly

This means that we're enforcing uniqueness of a rule name per approval
merge request type on MySQL, since partial indexes are not supported
there.

On postgres, `rule_type` was already part of the index, but as the
index is partial it would not apply for rules that are not code owner
rules.

[run mysql]
parent 2c9e17b6
......@@ -26,7 +26,7 @@ class AddIndexForCodeOwnerRuleTypeOnApprovalMergeRequestRules < ActiveRecord::Mi
# Ensure only 1 code_owner rule per merge_request
add_concurrent_index(
:approval_merge_request_rules,
[:merge_request_id, :name],
[:merge_request_id, :rule_type, :name],
unique: true,
where: "rule_type = #{ApprovalMergeRequestRule.rule_types[:code_owner]}",
name: INDEX_CODE_OWNERS_RULES_UNIQUENESS_NAME
......@@ -35,7 +35,7 @@ class AddIndexForCodeOwnerRuleTypeOnApprovalMergeRequestRules < ActiveRecord::Mi
# Support lookups for all code_owner rules per merge_request
add_concurrent_index(
:approval_merge_request_rules,
[:merge_request_id],
[:merge_request_id, :rule_type],
where: "rule_type = #{ApprovalMergeRequestRule.rule_types[:code_owner]}",
name: INDEX_CODE_OWNERS_RULES_QUERY_NAME
)
......
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