Skip to content
代码片段 群组 项目
未验证 提交 ed2c9051 编辑于 作者: Ian Anderson's avatar Ian Anderson 提交者: GitLab
浏览文件

Merge branch 'dlrussel/deleting-data-docs-update' into 'master'

Update data deletion guidelines documentation

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/184078



Merged-by: default avatarIan Anderson <ianderson@gitlab.com>
Approved-by: default avatarIan Anderson <ianderson@gitlab.com>
Reviewed-by: default avatarIan Anderson <ianderson@gitlab.com>
Co-authored-by: default avatarDiane Russel <drussel@gitlab.com>
No related branches found
No related tags found
2 合并请求!3031Merge per-main-jh to main-jh by luzhiyuan,!3030Merge per-main-jh to main-jh
...@@ -12,54 +12,30 @@ Generally, there are two ways to delete data: ...@@ -12,54 +12,30 @@ Generally, there are two ways to delete data:
- Mark for deletion: Identifies data for removal at a future date. This is the preferred approach. - Mark for deletion: Identifies data for removal at a future date. This is the preferred approach.
- Hard deletion: Immediately and permanently removes data. - Hard deletion: Immediately and permanently removes data.
## Mark for deletion ## Avoid direct hard deletion
You should avoid direct calls to hard delete classes, as this can lead to unintended data loss. Direct calls to hard delete classes should be avoided because it can lead to unintended data loss.
Specifically, avoid invoking the following classes:
{{< tabs >}} - `Projects::DestroyService`
- `ProjectDestroyWorker`
- `Groups::DestroyService`
- `GroupDestroyWorker`
{{< tab title="Projects" >}} ## Recommended approach
```ruby ### For projects
Projects::MarkForDeletionService.new(project, current_user).execute
```
{{< /tab >}} Instead of using `Projects::DestroyService`, use `Projects::MarkForDeletionService`.
{{< tab title="Groups" >}}
```ruby ```ruby
Groups::MarkForDeletionService.new(group, current_user).execute Projects::MarkForDeletionService.new(project, current_user).execute
```
{{< /tab >}}
{{< /tabs >}}
## Hard deletion
If you must delete data, use the following classes to hard delete from the codebase.
{{< tabs >}}
{{< tab title="Projects" >}}
```ruby
Projects::DestroyService.new(project, user, {}).execute
ProjectDestroyWorker.perform_async(project_id, user_id, params)
``` ```
{{< /tab >}} ### For groups
{{< tab title="Groups" >}} Instead of using `Groups::DestroyService`, use `Groups::MarkForDeletionService`.
```ruby ```ruby
Groups::MarkForDeletionService.new(group, current_user).execute Groups::MarkForDeletionService.new(group, current_user).execute
GroupDestroyWorker.new.perform(group_id, user_id)
``` ```
{{< /tab >}}
{{< /tabs >}}
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册