Critical fixes from code review: 1. **Moved auto-migration to correct location** - Now runs AFTER daemon check but BEFORE opening database - Prevents: database opened twice, conflicts with daemon - Was: Running too early, before knowing if daemon exists 2. **Fixed context cancellation issue** - Check if rootCtx is canceled before using it - Fall back to Background() if canceled - Fixes: "context canceled" errors in test suite 3. **Updated function signature** - Takes dbPath as parameter (no longer searches for it) - Simpler, more explicit, easier to test - Caller already has dbPath, no need to re-discover 4. **Enhanced test reliability** - Save/restore all global state - Add debug logging for troubleshooting - Verify preconditions before migration Changes: - cmd/bd/main.go: Move autoMigrateOnVersionBump call to correct location - cmd/bd/version_tracking.go: Fix context handling, update signature - cmd/bd/version_tracking_test.go: Improve test reliability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
13 KiB
13 KiB