Rename deletion_scheduled state to soft_deleted

Context

In https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/organization/lifecycle/ we propose to use soft-deleted instead of marked for deletion.

This issue is to perform the rename.

Proposal

In app/models/concerns/gitlab/tenant_container_lifecycle/stateful/transition_callbacks.rb:

  • Copy the set_deletion_schedule_data and clear_deletion_schedule_data methods to app/models/concerns/organizations/stateful.rb

In app/models/concerns/organizations/stateful.rb:

  • Rename the deletion_scheduled state to soft_deleted
  • Replace schedule_deletion with soft_delete
  • Replace set_deletion_schedule_data with set_soft_deletion_data
  • Replace clear_deletion_schedule_data with clear_soft_deletion_data
  • Replace deletion_scheduled_at with soft_deleted_at
  • Replace start_deletion with hard_delete
  • Replace cancel_deletion with restore
  • Remove the reschedule_deletion event

In app/models/organizations/organization_detail.rb:

  • Rename deletion_scheduled_by_user_id to soft_deletion_scheduled_by_user_id
  • Rename deletion_error to hard_deletion_error

In app/validators/json_schemas/organization_detail_state_metadata.json:

  • Make the relevant updates.

Rename app/services/organizations/mark_for_deletion_service.rb to app/services/organizations/soft_deletion_service.rb and update the file and callers accordingly to replace MarkForDeletionService with SoftDeletionService.

In app/services/organizations/soft_deletion_service.rb:

  • Replace schedule_deletion with soft_delete.
  • Replace deletion_scheduled? with soft_deleted?.
  • In #execute, replace "marked for deletion" with "deleted" (not using "soft deleted" since from the end-user perspective, the organization is actually deleted).
  • In #log_event, replace "Organization marked for deletion" with "Organization soft deleted" (since this is internal log event, we should state that the organization is soft deleted)

Follow https://docs.gitlab.com/development/database/avoiding_downtime_in_migrations/#renaming-columns to rename the deletion_scheduled_at column to soft_deleted_at.

Update specs accordingly.

Out of scope

  • Leave set_deletion_schedule_data and clear_deletion_schedule_data methods in app/models/concerns/gitlab/tenant_container_lifecycle/stateful/transition_callbacks.rb since they're still used by Namespaces::Stateful.
  • New services or API endpoints — this is a state-machine-only change.
Edited by 🤖 GitLab Bot 🤖