Skip to content
代码片段 群组 项目
未验证 提交 c9726c40 编辑于 作者: Kerri Miller's avatar Kerri Miller 提交者: Prabakaran Murugesan
浏览文件

Add patch_id_sha column to approvals

Add `patch_id_sha` column to eventually record the `patch_id`
of the most-current `merge_request_diff` when the approval is
created. We associate to `patch_id` rather than setting up an
ActiveRecord association to a `MergeRequestDiff` since the
approval is given against a _diff_, and the same diff (from a
functional perspective) can be included in multiple `MergeRequestDiff`
records (for instance, when an MR is rebased, the diff itself doesn't
functionally change, but a new `MergeRequestDiff` record is created.)
Adding this data to `approvals` records will help us detect when an
approval is still valid, even if new `MergeRequestDiffs` are created.

Related to https://gitlab.com/gitlab-org/gitlab/-/issues/422818

Prior related work: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/126920

Changelog: added
上级 5ab5e832
No related branches found
No related tags found
无相关合并请求
......@@ -3,10 +3,13 @@
class Approval < ApplicationRecord
include CreatedAtFilterable
include Importable
include ShaAttribute
belongs_to :user
belongs_to :merge_request
sha_attribute :patch_id_sha
validates :merge_request_id, presence: true, unless: :importing?
validates :user_id, presence: true, uniqueness: { scope: [:merge_request_id] }
......
# frozen_string_literal: true
class AddPatchIdShaOnApprovals < Gitlab::Database::Migration[2.1]
enable_lock_retries!
def up
add_column :approvals, :patch_id_sha, :binary
end
def down
remove_column :approvals, :patch_id_sha
end
end
ad75672df6de231df6d2702554e3416b0ba7c4c07cc4ace3d83595038f36b4e6
\ No newline at end of file
......@@ -12200,7 +12200,8 @@ CREATE TABLE approvals (
merge_request_id integer NOT NULL,
user_id integer NOT NULL,
created_at timestamp without time zone,
updated_at timestamp without time zone
updated_at timestamp without time zone,
patch_id_sha bytea
);
 
CREATE SEQUENCE approvals_id_seq
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册