feat(storage): add pinned field to issues schema

Add pinned column to the issues table to support persistent context markers
that should not be treated as work items (bd-7h5).

Changes:
- Add pinned column to schema.go CREATE TABLE
- Add migration 023_pinned_column.go for existing databases
- Update all issue queries to include pinned column
- Update scanIssues and scanIssuesWithDependencyType to handle pinned field
- Add Pinned field to types.Issue struct with JSON serialization
- Fix migrations_test.go to include pinned in legacy schema test

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-19 00:08:12 -08:00
parent 8e6462d44c
commit b1ba1c5315
12 changed files with 149 additions and 29 deletions

View File

@@ -0,0 +1,39 @@
package migrations
import (
"database/sql"
"fmt"
)
// MigratePinnedColumn adds the pinned column to the issues table.
// Pinned issues are persistent context markers that should not be treated as work items (bd-7h5).
func MigratePinnedColumn(db *sql.DB) error {
// Check if column already exists
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
}
// Add the pinned column
_, 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 index for pinned issues (for efficient filtering)
_, 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
}