fix: support delete in --no-db mode (GH#822)
Add CreateTombstone() to MemoryStorage and deleteBatchFallback() to handle deletion when SQLite is not available. This fixes the error "tombstone operation not supported by this storage backend" when using bd delete with --no-db flag. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
ee51298fd5
commit
b161e22144
@@ -474,6 +474,41 @@ func (m *MemoryStorage) CloseIssue(ctx context.Context, id string, reason string
|
||||
}, actor)
|
||||
}
|
||||
|
||||
// CreateTombstone converts an existing issue to a tombstone record.
|
||||
// This is a soft-delete that preserves the issue with status="tombstone".
|
||||
func (m *MemoryStorage) CreateTombstone(ctx context.Context, id string, actor string, reason string) error {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
issue, ok := m.issues[id]
|
||||
if !ok {
|
||||
return fmt.Errorf("issue not found: %s", id)
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
issue.OriginalType = string(issue.IssueType)
|
||||
issue.Status = types.StatusTombstone
|
||||
issue.DeletedAt = &now
|
||||
issue.DeletedBy = actor
|
||||
issue.DeleteReason = reason
|
||||
issue.UpdatedAt = now
|
||||
|
||||
// Mark as dirty for export
|
||||
m.dirty[id] = true
|
||||
|
||||
// Record tombstone creation event
|
||||
event := &types.Event{
|
||||
IssueID: id,
|
||||
EventType: "deleted",
|
||||
Actor: actor,
|
||||
Comment: &reason,
|
||||
CreatedAt: now,
|
||||
}
|
||||
m.events[id] = append(m.events[id], event)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteIssue permanently deletes an issue and all associated data
|
||||
func (m *MemoryStorage) DeleteIssue(ctx context.Context, id string) error {
|
||||
m.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user