feat: Auto-migrate database on CLI version bump (bd-jgxi)

When CLI is upgraded (e.g., 0.24.0 → 0.24.1), the database version
is now automatically updated to match the CLI version during
PersistentPreRun. This fixes the recurring UX issue where bd doctor
shows version mismatch after every CLI upgrade.

Implementation:
- Added autoMigrateOnVersionBump() function in version_tracking.go
- Calls after trackBdVersion() in PersistentPreRun
- Best-effort and silent failures to avoid disrupting commands
- Only updates bd_version metadata field
- Includes comprehensive test coverage

Changes:
- cmd/bd/main.go: Call autoMigrateOnVersionBump() in PersistentPreRun
- cmd/bd/version_tracking.go: Implement auto-migration logic
- cmd/bd/version_tracking_test.go: Add tests for auto-migration

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-23 18:09:24 -08:00
parent e76c7bec7c
commit 7796f5c7f5
4 changed files with 275 additions and 1 deletions

View File

@@ -302,6 +302,10 @@ var rootCmd = &cobra.Command{
// Best-effort tracking - failures are silent
trackBdVersion()
// Auto-migrate database on version bump (bd-jgxi)
// Best-effort migration - failures are silent to avoid disrupting commands
autoMigrateOnVersionBump()
// Initialize daemon status
socketPath := getSocketPath()
daemonStatus = DaemonStatus{