//! Startup checks the binary owes the database it opens. //! //! go-mcp is built from the same source as the desktop app and selects the //! columns that source assumes, so it has to apply pending migrations itself. //! Leaving that to the app made every window where the app had not been //! launched since a migration landed a window where every MCP read failed with //! a bare `no such column`, mid-session and with no clue attached. use std::path::Path; use goingson_db_sqlite::Db; /// Apply pending migrations, or explain what to run by hand. /// /// The error names the database and the command that closes the gap, because /// the failure a caller sees otherwise is a missing column with no context. pub fn migrate(db: &Db, db_path: &Path) -> Result<(), String> { goingson_db_sqlite::run_migrations(db).map_err(|e| { format!( "could not migrate {path}: {e}\n\ go-mcp will not serve a database whose schema it does not match.\n\ Close GoingsOn, back the file up, and run:\n \ cargo run -p goingson-db-sqlite --example migrate -- {path}", path = db_path.display() ) }) }