Skip to content

Records in merge_requests_closing_issues don't always close work items

What does this MR do and why?

A new column in the merge_requests_closing_issues table (closes_work_item) will indicate if the existence of the record means that the work item must be closed when the related MR is closed or not. All these changes make sure the existing closing pattern feature is not affected whenever we create a record in the merge_requests_closing_issues table is created with closes_work_item = false.

The table will be renamed in the future as described in #454136 we need a better name now that not all records will close the related issue

DB review

https://console.postgres.ai/gitlab/gitlab-production-main/sessions/27551/commands/85805
DELETE FROM 
  "merge_requests_closing_issues" 
WHERE 
  "merge_requests_closing_issues"."merge_request_id" = 20075985 
  AND "merge_requests_closing_issues"."closes_work_item" = TRUE

Steps to test

  1. Use the closing pattern feature in one of your MRs.
  2. In the Rails console manually create a new record on the same merge request but a different issue that the one used in the closing pattern
    MergeRequestsClosingIssues.create!(issue: issue, merge_request: merge_request, closes_work_item: false)
  3. Merge the merge request. Only the issue mentioned in the closing patter should be closed automatically (sidekiq needs to be running for this to work)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #455440 (closed)

Edited by Mario Celi

Merge request reports