Add backward-compatible mapping of legacy `push_rule` to `project_push_rules` during import
#### Problem Imports from older GitLab instances (within the [3 minor version compatibility window](https://docs.gitlab.com/user/project/settings/import_export/#compatibility)) will contain push rule records using the legacy `push_rules` schema. Once the `push_rules` table is deleted as part of the migration to `project_push_rules` (#499156), these imports will fail entirely. The importer needs a mapping layer that can detect legacy `push_rule` records and convert them to [`ProjectPushRule`](https://gitlab.com/gitlab-org/gitlab/-/blob/HEAD/ee/app/models/project_push_rule.rb) records. This was identified during investigation of #591680 and discussed in [this comment](https://gitlab.com/gitlab-org/gitlab/-/work_items/591680#note_3151341041). #### Prerequisites - #593333 - Add `project_push_rules` relation to project import/export - #593334 - Create Direct Transfer bulk import pipeline for `project_push_rules` #### Analysis The conversion is straightforward. All push rule setting columns are shared 1:1 between the two tables (both models use the [`PushRuleable`](https://gitlab.com/gitlab-org/gitlab/-/blob/HEAD/ee/app/models/concerns/push_ruleable.rb) concern): **Shared columns** (map directly): `max_file_size`, `member_check`, `prevent_secrets`, `commit_committer_name_check`, `deny_delete_tag`, `reject_unsigned_commits`, `commit_committer_check`, `reject_non_dco_commits`, `commit_message_regex`, `branch_name_regex`, `commit_message_negative_regex`, `author_email_regex`, `file_name_regex` **Legacy-only columns** (drop during mapping): `is_sample`, `regexp_uses_re2`, `organization_id` The current [EE `import_export.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/HEAD/lib/gitlab/import_export/project/import_export.yml) included attributes for `push_rule` include these legacy-only columns, confirming they will be present in old exports. #### Proposal 1. Add mapping logic in the [relation factory](https://gitlab.com/gitlab-org/gitlab/-/blob/HEAD/lib/gitlab/import_export/base/relation_factory.rb) (or equivalent location for Direct Transfer) to detect legacy `push_rule` records from old exports and convert them to `ProjectPushRule` by: - Dropping `is_sample`, `regexp_uses_re2`, and `organization_id` attributes - Writing the remaining attributes to the `ProjectPushRule` model 2. Add tests covering: - Import of an old export containing a legacy `push_rule` record results in a `ProjectPushRule` - Attributes are correctly mapped - Uniqueness is enforced (no duplicate push rules created if project already has one) #### Related issues - #591680 - `ActiveRecord::RecordInvalid: Validation failed: Project has already been taken` - #499156 - Push rules table migration tracking - #593331 - Add group push rules to group import/export
issue