Nullify merge_request_metrics pipeline_id on pipeline deletion
What does this MR do and why?
Before, when a pipeline is deleted, the associated merge_request_metrics
record will be deleted as well. This is a destructive thing as merge_request_metrics
include other data not related to a pipeline.
To fix this issue, instead of deleting the association record, we nullify the pipeline_id
on merge_request_metrics
instead. When this happens, related build data (latest_build_started_at
and latest_build_finished_at
) will be nullified as well. This is to ensure that when those data are requested, it'll still behave the same way as before.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Run migration.
- Create a MR with pipeline.
- Let the pipeline run.
- Merge the MR.
- Delete the pipeline.
- Wait for 2 minutes (this is to ensure the job to clean up loose foreign keys has already ran).
- Make a request to
api/v4/projects/:project_id/merge_requests/:merge_request_iid
and check ifmerged_at
is not null.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.