[Data migration] Multiple blocking merge request approval rules
Migration part for the issue #1979 (closed), to allow one MR to have multiple approval rules, each with different members/ approval required settings.
!8497 (merged)
Migration-
ApprovalMergeRequestRule
andApprovalProjectRule
models are created - Those two rules model will ahve HABTM relationship to
User
andGroup
. - Existing
Approver
andAppoverGroup
models will be deprecated. - Similar to before, MR's
ApprovalRule
will override ProjectApprovalRule
. -
approval_rules_approvals
are created, a HABTM table betweenapprovals
andapproval_merge_request_rules
.
!8669 (merged)
Data migration- The old model
Approver
andAppoverGroup
will be migrated to the new models. - Projects will be migrated first, and its merge requests then migrated.
When MR without overriding
ApprovalRule
is merged, the project'sApprovalRule
will be copied over (MergeRequest#finalize_approvals
). - When
Approver/ApproverGroup
is added/removed,ApprovalRule
will be synced accordingly.
How is data being persisted before/after merge
The way models are finalized after merge can vary a bit. To illustrate the 3 scenarios, let's assume when MR is still open, the yellow rows are present:
1. When MR rule override exists
The blue rows are created once the MR is merged, recording which user approved which rule.
2. Project rule without MR rule override
The blue rows are created once the MR is merged, which are copying the project level rules as MR rules, and then approved_approvers
.
3. Project rule without MR rule override, with code owner
Code owner rule always exists at MR level:
Iteration Plan
-
Create new tables
Migrate old data to new tables
-
A data migration to run for each project -
A data migration to run for each merge request
Hooks to ensure data changes are reflected in new model
-
Add hooks for approver/approver_group changes -
Add hooks for merge request 'approvals required' changes -
Add hooks for project 'approvals required' changes -
Ensure merged merge request's approval related records are no longer changed.
Investigate how code owner data can be migrated
-
When merge request is created/updated, update code owner rule
Edited by Mark Chao