feat(list): add --pinned and --no-pinned filter flags
Add ability to filter issues by their pinned status in bd list command. - Add pinned column to issues table via migration 023 - Add Pinned field to Issue struct and IssueFilter - Update all storage layer queries to include pinned column - Add --pinned flag to show only pinned issues - Add --no-pinned flag to exclude pinned issues - Update RPC layer to forward pinned filter to daemon mode - Add pinned to allowedUpdateFields for bd update support Resolves: beads-p8e 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
37
internal/storage/sqlite/migrations/023_pinned_column.go
Normal file
37
internal/storage/sqlite/migrations/023_pinned_column.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MigratePinnedColumn adds the pinned column to the issues table.
|
||||
// Pinned issues are visually marked and can be filtered with --pinned/--no-pinned flags.
|
||||
func MigratePinnedColumn(db *sql.DB) error {
|
||||
var columnExists bool
|
||||
err := db.QueryRow(`
|
||||
SELECT COUNT(*) > 0
|
||||
FROM pragma_table_info('issues')
|
||||
WHERE name = 'pinned'
|
||||
`).Scan(&columnExists)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check pinned column: %w", err)
|
||||
}
|
||||
|
||||
if columnExists {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err = db.Exec(`ALTER TABLE issues ADD COLUMN pinned INTEGER DEFAULT 0`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add pinned column: %w", err)
|
||||
}
|
||||
|
||||
// Add partial index for efficient pinned issue queries
|
||||
_, err = db.Exec(`CREATE INDEX IF NOT EXISTS idx_issues_pinned ON issues(pinned) WHERE pinned = 1`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create pinned index: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user