Add soft delete status management for Projects and Resource Groups
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## Summary
Replace the current `is_active` boolean with a proper status enum to support soft delete semantics, allowing deleted objects to be retained until the history retention limit.
## Current State
- `GroupRow` has `is_active: bool` field
- `ScalingGroupRow` has `is_active: bool` field
- Deletion either fails (FK constraints) or hard-deletes the record
## Proposed Changes
### New Status Enums
```python
class ProjectStatus(enum.StrEnum):
ACTIVE = "active"
DELETED = "deleted"
class ScalingGroupStatus(enum.StrEnum):
ACTIVE = "active"
DELETED = "deleted"
```
### Database Changes
1. Add `status` column to `groups` table (default: ACTIVE)
1. Add `status` column to `scaling_groups` table (default: ACTIVE)
1. Add `deleted_at` timestamp column to both tables
1. Migrate existing `is_active=False` records to `status=DELETED`
### API Changes
- `delete_project` API marks status as DELETED (no hard delete)
- `purge_project` API performs hard delete (admin only, after retention period)
- List/query APIs filter out DELETED status by default
- Add `include_deleted` parameter for admin queries
## Technical Approach
1. Create Alembic migration for schema changes
1. Update Row classes with new columns
1. Update Repository queries to filter by status
1. Modify delete service methods to set status instead of hard delete
1. Add purge service methods for actual deletion
## Acceptance Criteria
- [ ] Status enum columns added to groups and scaling_groups tables
- [ ] Delete API marks records as DELETED instead of removing
- [ ] Normal queries exclude DELETED records
- [ ] Admin can query deleted records with flag
- [ ] Purge API available for hard deletion
- [ ] Migration handles existing is_active=False records
JIRA Issue: BA-3711
Contributor guide
Assessment
This issue has not been assessed yet.