feat(types): add tombstone support for inline soft-delete (bd-fbj)
Add tombstone types and schema migration as foundation for the tombstone epic (bd-vw8) which replaces deletions.jsonl with inline tombstones. Changes: - Add tombstone fields to Issue struct: DeletedAt, DeletedBy, DeleteReason, OriginalType - Add StatusTombstone constant and IsTombstone() helper method - Update Status.IsValid() to accept tombstone status - Create migration 018_tombstone_columns.go for new database columns - Update schema.go with tombstone columns: deleted_at, deleted_by, delete_reason, original_type - Update all issue insert/update/scan operations across: - issues.go (insertIssue, insertIssues) - queries.go (GetIssue, GetIssueByExternalRef, SearchIssues) - dependencies.go (scanIssues, scanIssuesWithDependencyType) - transaction.go (scanIssueRow, GetIssue, SearchIssues) - multirepo.go (import operations) - ready.go (GetReadyWork, GetStaleIssues) - labels.go (GetIssuesByLabel) - Add test for IsTombstone() helper - Update migration test to include tombstone columns Unblocks: bd-olt (TTL logic), bd-3b4 (delete command), bd-0ih (merge updates), bd-dve (import/export) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,11 @@ type Issue struct {
|
||||
Labels []string `json:"labels,omitempty"` // Populated only for export/import
|
||||
Dependencies []*Dependency `json:"dependencies,omitempty"` // Populated only for export/import
|
||||
Comments []*Comment `json:"comments,omitempty"` // Populated only for export/import
|
||||
// Tombstone fields (bd-vw8): inline soft-delete support
|
||||
DeletedAt *time.Time `json:"deleted_at,omitempty"` // When the issue was deleted
|
||||
DeletedBy string `json:"deleted_by,omitempty"` // Who deleted the issue
|
||||
DeleteReason string `json:"delete_reason,omitempty"` // Why the issue was deleted
|
||||
OriginalType string `json:"original_type,omitempty"` // Issue type before deletion (for tombstones)
|
||||
}
|
||||
|
||||
// ComputeContentHash creates a deterministic hash of the issue's content.
|
||||
@@ -69,6 +74,11 @@ func (i *Issue) ComputeContentHash() string {
|
||||
return fmt.Sprintf("%x", h.Sum(nil))
|
||||
}
|
||||
|
||||
// IsTombstone returns true if the issue has been soft-deleted (bd-vw8)
|
||||
func (i *Issue) IsTombstone() bool {
|
||||
return i.Status == StatusTombstone
|
||||
}
|
||||
|
||||
// Validate checks if the issue has valid field values (built-in statuses only)
|
||||
func (i *Issue) Validate() error {
|
||||
return i.ValidateWithCustomStatuses(nil)
|
||||
@@ -114,12 +124,13 @@ const (
|
||||
StatusInProgress Status = "in_progress"
|
||||
StatusBlocked Status = "blocked"
|
||||
StatusClosed Status = "closed"
|
||||
StatusTombstone Status = "tombstone" // Soft-deleted issue (bd-vw8)
|
||||
)
|
||||
|
||||
// IsValid checks if the status value is valid (built-in statuses only)
|
||||
func (s Status) IsValid() bool {
|
||||
switch s {
|
||||
case StatusOpen, StatusInProgress, StatusBlocked, StatusClosed:
|
||||
case StatusOpen, StatusInProgress, StatusBlocked, StatusClosed, StatusTombstone:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -202,6 +202,7 @@ func TestStatusIsValid(t *testing.T) {
|
||||
{StatusInProgress, true},
|
||||
{StatusBlocked, true},
|
||||
{StatusClosed, true},
|
||||
{StatusTombstone, true},
|
||||
{Status("invalid"), false},
|
||||
{Status(""), false},
|
||||
}
|
||||
@@ -215,6 +216,79 @@ func TestStatusIsValid(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsTombstone(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
issue Issue
|
||||
expect bool
|
||||
}{
|
||||
{
|
||||
name: "tombstone issue",
|
||||
issue: Issue{
|
||||
ID: "test-1",
|
||||
Title: "(deleted)",
|
||||
Status: StatusTombstone,
|
||||
Priority: 0,
|
||||
IssueType: TypeTask,
|
||||
},
|
||||
expect: true,
|
||||
},
|
||||
{
|
||||
name: "open issue",
|
||||
issue: Issue{
|
||||
ID: "test-1",
|
||||
Title: "Open issue",
|
||||
Status: StatusOpen,
|
||||
Priority: 2,
|
||||
IssueType: TypeTask,
|
||||
},
|
||||
expect: false,
|
||||
},
|
||||
{
|
||||
name: "closed issue",
|
||||
issue: Issue{
|
||||
ID: "test-1",
|
||||
Title: "Closed issue",
|
||||
Status: StatusClosed,
|
||||
Priority: 2,
|
||||
IssueType: TypeTask,
|
||||
ClosedAt: timePtr(time.Now()),
|
||||
},
|
||||
expect: false,
|
||||
},
|
||||
{
|
||||
name: "in_progress issue",
|
||||
issue: Issue{
|
||||
ID: "test-1",
|
||||
Title: "In progress issue",
|
||||
Status: StatusInProgress,
|
||||
Priority: 2,
|
||||
IssueType: TypeTask,
|
||||
},
|
||||
expect: false,
|
||||
},
|
||||
{
|
||||
name: "blocked issue",
|
||||
issue: Issue{
|
||||
ID: "test-1",
|
||||
Title: "Blocked issue",
|
||||
Status: StatusBlocked,
|
||||
Priority: 2,
|
||||
IssueType: TypeTask,
|
||||
},
|
||||
expect: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := tt.issue.IsTombstone(); got != tt.expect {
|
||||
t.Errorf("Issue.IsTombstone() = %v, want %v", got, tt.expect)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatusIsValidWithCustom(t *testing.T) {
|
||||
customStatuses := []string{"awaiting_review", "awaiting_testing", "awaiting_docs"}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user