Rename deletion_scheduled state to soft_deleted in Organizations
What does this MR do and why?
Renames the organization-specific state machine terminology from deletion_scheduled to soft_deleted, aligning with the organization lifecycle architecture design document.
Previously, organizations went through multiple deletion states: they could be "scheduled for deletion," then moved to "deletion in progress," and could be rescheduled or cancelled at various points. This created a complex workflow with multiple intermediate states and error handling.
The new approach simplifies this to just two main actions: "soft delete" (which marks an organization as deleted but keeps the data) and "restore" (which undoes the soft deletion). Organizations can also be "hard deleted" which permanently removes them.
Key changes include:
- Renaming the database column from
deletion_scheduled_attosoft_deleted_atto better reflect its purpose - Updating the state machine to use
soft_deletedinstead ofdeletion_scheduled - Simplifying the service class from
MarkForDeletionServicetoSoftDeletionService - Removing complex rescheduling and cancellation logic in favor of simple restore functionality
- Updating audit logs and error messages to reflect the new terminology
This makes the deletion process more straightforward for users and easier to maintain for developers, while still preserving the ability to recover accidentally deleted organizations.
References
- Issue: Rename deletion_scheduled state to soft_deleted (#600041 - closed)
- Also implements Disallow deletion_in_progress → active transiti... (#599342 - closed)
- Architecture doc: https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/organization/lifecycle/
Screenshots or screen recordings
N/A — backend-only change.
How to set up and validate locally
- Run the migrations:
bundle exec rails db:migrate - In rails console, verify the new state machine:
org = Organizations::Organization.find(2) # any non-default org org.soft_delete!(transition_user: User.first) org.soft_deleted? # => true org.restore! org.active? # => true - Run the specs:
bundle exec rspec spec/models/concerns/organizations/stateful_spec.rb bundle exec rspec spec/services/organizations/soft_deletion_service_spec.rb
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.