[go: up one dir, main page]

Skip to content

[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.

Migration !8497 (merged)

1979-model.svg

  • ApprovalMergeRequestRule and ApprovalProjectRule models are created
  • Those two rules model will ahve HABTM relationship to User and Group.
  • Existing Approver and AppoverGroup models will be deprecated.
  • Similar to before, MR's ApprovalRule will override Project ApprovalRule.
  • approval_rules_approvals are created, a HABTM table between approvals and approval_merge_request_rules.

Data migration !8669 (merged)

  • The old model Approver and AppoverGroup 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's ApprovalRule will be copied over (MergeRequest#finalize_approvals). migration
  • 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

1979-model-mr-level.svg

The blue rows are created once the MR is merged, recording which user approved which rule.

2. Project rule without MR rule override

1979-model-project-level

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:

1979-model-project-level-with-co

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