feat: add crystallizes column to sqlite storage

Adds crystallizes column for work economics (compounds vs evaporates)
per Decision 006. Includes migration 036 and updates to all INSERT/SELECT
queries in issues.go, queries.go, dependencies.go, and transaction.go.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
beads/crew/fang
2026-01-10 23:42:58 -08:00
committed by Steve Yegge
parent 0ed349b3ed
commit f5cd36752d
6 changed files with 97 additions and 17 deletions

View File

@@ -0,0 +1,36 @@
package migrations
import (
"database/sql"
"fmt"
)
// MigrateCrystallizesColumn adds the crystallizes column to the issues table.
// Crystallizes tracks whether work compounds over time (true: code, features)
// or evaporates (false: ops, support). Per Decision 006, this affects CV weighting.
// Default is false (conservative - work evaporates unless explicitly marked).
func MigrateCrystallizesColumn(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 = 'crystallizes'
`).Scan(&columnExists)
if err != nil {
return fmt.Errorf("failed to check crystallizes column: %w", err)
}
if columnExists {
// Column already exists (e.g. created by new schema)
return nil
}
// Add the crystallizes column
_, err = db.Exec(`ALTER TABLE issues ADD COLUMN crystallizes INTEGER DEFAULT 0`)
if err != nil {
return fmt.Errorf("failed to add crystallizes column: %w", err)
}
return nil
}