fix(api): delete orphaned sessions when character is deleted

- Add delete_sessions_by_character() method to SessionService that
  cleans up all game sessions associated with a character
- Update delete_character() to hard delete instead of soft delete
- Call session cleanup before deleting character to prevent orphaned data
- Delete associated chat messages when cleaning up sessions
- Update API documentation to reflect new behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-26 10:46:35 -06:00
parent 1b21465dc4
commit 98bb6ab589
4 changed files with 92 additions and 7 deletions

View File

@@ -463,7 +463,7 @@ Set-Cookie: coc_session=<session_token>; HttpOnly; Secure; SameSite=Lax; Max-Age
| | |
|---|---|
| **Endpoint** | `DELETE /api/v1/characters/<id>` |
| **Description** | Delete character (soft delete - marks as inactive) |
| **Description** | Permanently delete character and all associated game sessions |
| **Auth Required** | Yes |
**Response (200 OK):**

View File

@@ -634,7 +634,7 @@ curl -X POST http://localhost:5000/api/v1/characters \
**Endpoint:** `DELETE /api/v1/characters/<character_id>`
**Description:** Soft-delete a character (marks as inactive rather than removing).
**Description:** Permanently delete a character from the database. Also cleans up all associated game sessions to prevent orphaned data.
**Request:**