feat(types): add template molecules infrastructure for beads-1ra
Add support for template molecules (is_template field and TypeMolecule type): - Add IsTemplate field to Issue type with JSON support - Add TypeMolecule constant to IssueType constants - Add IsTemplate filter to IssueFilter for querying - Update all SQL queries to include is_template column - Add migration 024 for is_template column - Add FindMoleculesJSONLInDir helper for molecules.jsonl path detection This enables treating certain issues as read-only templates that can be instantiated to create work items. The template flag allows separating template molecules from regular work items in queries and exports. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
40
internal/storage/sqlite/migrations/024_is_template_column.go
Normal file
40
internal/storage/sqlite/migrations/024_is_template_column.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MigrateIsTemplateColumn adds the is_template column to the issues table.
|
||||
// Template issues (molecules) are read-only templates that should be filtered
|
||||
// from work views by default (beads-1ra).
|
||||
func MigrateIsTemplateColumn(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 = 'is_template'
|
||||
`).Scan(&columnExists)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check is_template column: %w", err)
|
||||
}
|
||||
|
||||
if columnExists {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Add the is_template column
|
||||
_, err = db.Exec(`ALTER TABLE issues ADD COLUMN is_template INTEGER DEFAULT 0`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add is_template column: %w", err)
|
||||
}
|
||||
|
||||
// Add index for template issues (for efficient filtering)
|
||||
_, err = db.Exec(`CREATE INDEX IF NOT EXISTS idx_issues_is_template ON issues(is_template) WHERE is_template = 1`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create is_template index: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user