Add merged_commit_sha to queries looking for related merge requests

Problem to solve

In #418822 (closed) we added a column merged_commit_sha to merge_requests that tracks merged commit SHAs, regardless of the merge method, but we did not update any queries that required an index. We need to update related queries so that automatically rebased fast-forward merge train merges show up in the right places.

Proposal

In particular, MergeRequest.by_related_commit_sha should be updated, but scoped into the issue is surveying the code for other queries that might need to be updated. They can be found by tracing uses of merge_commit_sha and squash_commit_sha in the code.

This should happen one milestone after !131682 (merged) is released, because it is a post-deployment migration.

Availability and Testing

Regression testing, please ensure associated MR is labelled with pipeline:run-all-e2e and e2e:package-and-test job is passing.

Edited by Jay McCure