diff --git a/cmd/bd/daemon.go b/cmd/bd/daemon.go index bea99103..318bda1e 100644 --- a/cmd/bd/daemon.go +++ b/cmd/bd/daemon.go @@ -288,24 +288,24 @@ func runDaemonLoop(interval time.Duration, autoCommit, autoPush bool, logPath, p } if dbVersion != "" && dbVersion != Version { - log.log("Error: Database schema version mismatch") + log.log("Warning: Database schema version mismatch") log.log(" Database version: %s", dbVersion) log.log(" Daemon version: %s", Version) - log.log("") - log.log("The database was created with a different version of bd.") - log.log("This may cause compatibility issues.") - log.log("") - log.log("Options:") - log.log(" 1. Run 'bd migrate' to update the database to the current version") - log.log(" 2. Upgrade/downgrade bd to match database version: %s", dbVersion) - log.log(" 3. Set BEADS_IGNORE_VERSION_MISMATCH=1 to proceed anyway (not recommended)") - log.log("") + log.log(" Auto-upgrading database to daemon version...") - // Allow override via environment variable for emergencies - if os.Getenv("BEADS_IGNORE_VERSION_MISMATCH") != "1" { - os.Exit(1) + // Auto-upgrade database to daemon version + // The daemon operates on its own database, so it should always use its own version + if err := store.SetMetadata(versionCtx, "bd_version", Version); err != nil { + log.log("Error: failed to update database version: %v", err) + + // Allow override via environment variable for emergencies + if os.Getenv("BEADS_IGNORE_VERSION_MISMATCH") != "1" { + os.Exit(1) + } + log.log("Warning: Proceeding despite version update failure (BEADS_IGNORE_VERSION_MISMATCH=1)") + } else { + log.log(" Database version updated to %s", Version) } - log.log("Warning: Proceeding despite version mismatch (BEADS_IGNORE_VERSION_MISMATCH=1)") } else if dbVersion == "" { // Old database without version metadata - set it now log.log("Warning: Database missing version metadata, setting to %s", Version)