Pinned issues are persistent anchors that should not appear in ready work lists. This adds: - Pinned bool field to Issue struct - pinned INTEGER DEFAULT 0 column to schema - Migration 023 to add pinned column to existing databases - WHERE i.pinned = 0 filter in GetReadyWork query 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
39 lines
976 B
Go
39 lines
976 B
Go
package migrations
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
)
|
|
|
|
// MigratePinnedColumn adds the pinned column to the issues table.
|
|
// Pinned issues are persistent anchors that should be excluded from bd ready (bd-92u).
|
|
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
|
|
}
|
|
|
|
_, 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 pinned issues (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
|
|
}
|