Migrate duplicate push_rules to project_push_rules
What does this MR do and why?
This MR migrates duplicate push_rules to project_push_rules
using environment-specific logic:
- GitLab.com: Selects duplicate with lowest ID (MIN) to match
order(:id)behavior whenpush_rule_ordered_by_idfeature flag is enabled - Self-managed: Uses LIMIT 1 without ORDER BY to preserve implicit database ordering that customers have been relying on
This maintains consistency with existing project.push_rule association
behavior across different environments.
Query Plans
- The migrate_duplicates_with_explicit_ordering(sub_batch) uses the order provided in code: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/45521/commands/139530
- The migrate_duplicates_with_implicit_ordering(sub_batch) uses 4 internal queries for lookup
- First to find project_ids that have duplicate push rules: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/45521/commands/139531
- Second to check if any project_push_rules have already been created for the projects: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/45521/commands/139532
- Third query which mimics the current call we make when we call project.push_rule in app: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/45521/commands/139533
- Then a 4th query which is an insert
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
MR acceptance checklist
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 #499156
Edited by Olaoluwa Oluro