Fix config version update in migrate command

- Save updated config with current version (fixes GH #193)
- Update version field when loading existing config
- Database version now stays in sync with binary version

Amp-Thread-ID: https://ampcode.com/threads/T-dfacc972-f6c8-4bb3-8997-faa079b5d070
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-11-02 12:55:53 -08:00
parent 7d6d64d2c1
commit 0cfe741553
2 changed files with 14 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
{ {
"database": "beads.db", "database": "beads.db",
"version": "0.21.0", "version": "0.21.3",
"jsonl_export": "beads.jsonl" "jsonl_export": "beads.jsonl"
} }

View File

@@ -440,6 +440,16 @@ This command:
} }
} }
// Save updated config with current version (fixes GH #193)
if !dryRun {
if err := cfg.Save(beadsDir); err != nil {
if !jsonOutput {
color.Yellow("Warning: failed to update config.json version: %v\n", err)
}
// Don't fail migration if config save fails
}
}
// Final status // Final status
if jsonOutput { if jsonOutput {
outputJSON(map[string]interface{}{ outputJSON(map[string]interface{}{
@@ -667,6 +677,9 @@ func loadOrCreateConfig(beadsDir string) (*configfile.Config, error) {
// Create default if no config exists // Create default if no config exists
if cfg == nil { if cfg == nil {
cfg = configfile.DefaultConfig(Version) cfg = configfile.DefaultConfig(Version)
} else {
// Update version field in existing config (fixes GH #193)
cfg.Version = Version
} }
return cfg, nil return cfg, nil