feat: Add bd repair command for orphaned foreign key refs (hq-2cchm)

When the database has orphaned dependencies or labels, the migration
invariant check fails and prevents the database from opening. This
creates a chicken-and-egg problem where bd doctor --fix cannot run.

The new bd repair command:
- Opens SQLite directly, bypassing invariant checks
- Deletes orphaned dependencies (issue_id or depends_on_id not in issues)
- Deletes orphaned labels (issue_id not in issues)
- Runs WAL checkpoint to persist changes
- Supports --dry-run to preview what would be cleaned

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-29 12:43:05 -08:00
parent 93cc9df9ad
commit 1facf7fb83
3 changed files with 509 additions and 0 deletions

View File

@@ -281,6 +281,7 @@ var rootCmd = &cobra.Command{
"powershell",
"prime",
"quickstart",
"repair",
"setup",
"version",
"zsh",