Skip to content

Resolve "Store the number of merge request commits in merge_request_diffs.commits_count"

Jan Provaznik requested to merge 38068-commits-count into master

What does this MR do?

Stores the number of commits in merge_request_diffs table.

Are there points in the code the reviewer needs to double check?

  • background migration was tested only on local small DB. This change may be potentially dangerous if an existing migration creates MergeRequestDiff ActiveRecord's object (in such case the migration would fails because commits_count attribute wouldn't be in DB yet). I didn't find such migration except an existing migration test (where commits_count access is stubbed now). Tested only on local DB including rollbacks 3 months back.
  • commits_count is set only when creating a MergeRequestDiff supposing that there is no other place where commits could be created. If it's possible to create or destroy MergeRequestDiffCommit independently, an extra before_create and before_destroy callbacks on MergeRequestDiffCommit would be needed

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #38068 (closed)

Edited by Yorick Peterse

Merge request reports