Data deletion guidelines
In order to minimize the risk of accidental data loss, GitLab provides guidelines for how to safely use deletion operations in the codebase.
Generally, there are two ways to delete data:
- Mark for deletion: Identifies data for removal at a future date. This is the preferred approach.
- Hard deletion: Immediately and permanently removes data.
Avoid direct hard deletion
Direct calls to hard delete classes should be avoided because it can lead to unintended data loss. Specifically, avoid invoking the following classes:
Projects::DestroyService
ProjectDestroyWorker
Groups::DestroyService
GroupDestroyWorker
Recommended approach
For projects
Instead of using Projects::DestroyService
, use Projects::MarkForDeletionService
.
Projects::MarkForDeletionService.new(project, current_user).execute
For groups
Instead of using Groups::DestroyService
, use Groups::MarkForDeletionService
.
Groups::MarkForDeletionService.new(group, current_user).execute
Docs
Edit this page to fix an error or add an improvement in a merge request.
Create an issue to suggest an improvement to this page.
Product
Create an issue if there's something you don't like about this feature.
Propose functionality by submitting a feature request.
Feature availability and product trials
View pricing to see all GitLab tiers and features, or to upgrade.
Try GitLab for free with access to all features for 30 days.
Get help
If you didn't find what you were looking for, search the docs.
If you want help with something specific and could use community support, post on the GitLab forum.
For problems setting up or using this feature (depending on your GitLab subscription).
Request support