- Add Pinned field to Issue struct in types.go - Create migration 023 to add pinned column with partial index - Update SQLite GetBlockedIssues to filter WHERE pinned = 0 - Update Memory GetBlockedIssues to skip pinned issues - Update schema.go with pinned column definition Pinned issues are tracked but excluded from the blocked list to reduce noise for issues that are intentionally parked. Closes: beads-ei4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
40 lines
987 B
Go
40 lines
987 B
Go
package migrations
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
)
|
|
|
|
// MigratePinnedColumn adds the pinned column to the issues table.
|
|
// Pinned issues are excluded from bd blocked output (beads-ei4).
|
|
func MigratePinnedColumn(db *sql.DB) error {
|
|
// Check if column 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 pinned column (default false = 0)
|
|
_, 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 queries on pinned issues
|
|
_, 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
|
|
}
|