Skip to content

Bug: Chat deletion permanently removes records instead of soft delete, breaking compliance/audit trail #211

@featuringmyself

Description

@featuringmyself

🐛 Problem
The chat deletion functionality is using hard delete (prismaClient.execution.delete()) which permanently removes chat records from the database. This creates compliance and audit issues, and prevents implementing an "undo delete" feature.
🔍 Current Behavior
javascriptawait prismaClient.execution.delete({
where: {
id: chatId
}
})

Chat records are permanently removed from database
No audit trail of deleted chats
Cannot recover accidentally deleted chats
Potential compliance violations

✅ Expected Behavior

Chat should be marked as deleted (soft delete) using a deletedAt timestamp or isDeleted boolean flag
Original chat data should remain in database for audit purposes
Should enable "undo delete" functionality
Maintain compliance with data retention policies

🔧 Suggested Solution
Replace hard delete with soft delete:

await prismaClient.execution.update({
where: {
id: chatId
},
data: {
deletedAt: new Date(),
// or isDeleted: true
}
})

📋 Acceptance Criteria

Chat deletion marks record as deleted instead of removing it
Deleted chats are filtered out of normal queries
Audit trail is maintained for compliance
"Undo delete" functionality can be implemented
Database migration handles existing data appropriately

🎯 Impact

Compliance Risk: High - Could cause audit failures
User Experience: Medium - No recovery option for accidental deletions
Technical Debt: Medium - Blocks undo functionality implementation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions