Update partitioned relations to use query_constraints

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

In !130073 (merged) we have defined partitioned relations as:

belongs_to :pipeline, ->(build) { in_partition(build) }, class_name: 'Ci::Pipeline', foreign_key: :commit_id, partition_foreign_key: :partition_id, inverse_of: :builds

But Rails 7.1 added a way to specify composite foreign keys on a relation using query_constraints:

belongs_to :pipeline, class_name: 'Ci::Pipeline', query_constraints: [:pipeline_id, :partition_id], inverse_of: :builds

We should update these relations after upgrading to Rails 7.1: &11470

Edited by 🤖 GitLab Bot 🤖