Files
beads/internal/storage/sqlite/migrations/029_created_by_column.go
Steve Yegge c3ef1c3f38 feat: Add created_by field to issues (GH#748)
Add a created_by field to track who created each issue, similar to how
comments have an author field.

- Add CreatedBy string field to Issue struct
- Add migration 029 to add created_by column to issues table
- Update all SELECT/INSERT/Scan statements across storage layer
- Populate created_by in bd create from actor chain
- Display created_by in bd show output

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 13:33:54 -08:00

35 lines
831 B
Go

package migrations
import (
"database/sql"
"fmt"
)
// MigrateCreatedByColumn adds the created_by column to the issues table.
// This tracks who created the issue, using the same actor chain as comment authors
// (--actor flag, BD_ACTOR env, or $USER). GH#748.
func MigrateCreatedByColumn(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 = 'created_by'
`).Scan(&columnExists)
if err != nil {
return fmt.Errorf("failed to check created_by column: %w", err)
}
if columnExists {
return nil
}
// Add the created_by column
_, err = db.Exec(`ALTER TABLE issues ADD COLUMN created_by TEXT DEFAULT ''`)
if err != nil {
return fmt.Errorf("failed to add created_by column: %w", err)
}
return nil
}