feat: consolidate schema changes from crew directories
Merges schema additions from crew/fang, crew/giles, crew/grip, and crew/wolf: - crystallizes: bool field for work economics (compounds vs evaporates) - work_type: WorkType field for assignment model (mutex vs open_competition) - source_system: string field for federation adapter tracking - quality_score: *float32 for aggregate quality (0.0-1.0) - delegated-from: new dependency type for work delegation chains Migrations properly sequenced as 037-040 (after existing 036 owner_column). Also fixes test compilation errors for removed TypeRig and IsBuiltIn references. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Executed-By: beads/crew/dave Rig: beads Role: crew
This commit is contained in:
committed by
Steve Yegge
parent
8942261a12
commit
f79e636000
@@ -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
|
||||
}
|
||||
34
internal/storage/sqlite/migrations/038_work_type_column.go
Normal file
34
internal/storage/sqlite/migrations/038_work_type_column.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MigrateWorkTypeColumn adds work_type column to the issues table.
|
||||
// This field distinguishes work assignment models per Decision 006.
|
||||
// Values: 'mutex' (one worker, exclusive - default) or 'open_competition' (many submit, buyer picks)
|
||||
func MigrateWorkTypeColumn(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 = 'work_type'
|
||||
`).Scan(&columnExists)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check work_type column: %w", err)
|
||||
}
|
||||
|
||||
if columnExists {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Add the column with default 'mutex'
|
||||
_, err = db.Exec(`ALTER TABLE issues ADD COLUMN work_type TEXT DEFAULT 'mutex'`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add work_type column: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MigrateSourceSystemColumn adds the source_system column to the issues table.
|
||||
// This tracks which adapter/system created the issue for federation support.
|
||||
func MigrateSourceSystemColumn(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 = 'source_system'
|
||||
`).Scan(&columnExists)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check source_system column: %w", err)
|
||||
}
|
||||
|
||||
if columnExists {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Add the source_system column
|
||||
_, err = db.Exec(`ALTER TABLE issues ADD COLUMN source_system TEXT DEFAULT ''`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add source_system column: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MigrateQualityScoreColumn adds the quality_score column to the issues table.
|
||||
// This stores an aggregate quality score (0.0-1.0) set by Refineries on merge.
|
||||
// NULL indicates no score has been assigned yet.
|
||||
func MigrateQualityScoreColumn(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 = 'quality_score'
|
||||
`).Scan(&columnExists)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check quality_score column: %w", err)
|
||||
}
|
||||
|
||||
if columnExists {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Add the quality_score column (REAL, nullable - no default)
|
||||
_, err = db.Exec(`ALTER TABLE issues ADD COLUMN quality_score REAL`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add quality_score column: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user