max / goingson
| 1 | //! Startup checks the binary owes the database it opens. |
| 2 | //! |
| 3 | //! go-mcp is built from the same source as the desktop app and selects the |
| 4 | //! columns that source assumes, so it has to apply pending migrations itself. |
| 5 | //! Leaving that to the app made every window where the app had not been |
| 6 | //! launched since a migration landed a window where every MCP read failed with |
| 7 | //! a bare `no such column`, mid-session and with no clue attached. |
| 8 | |
| 9 | use Path; |
| 10 | |
| 11 | use Db; |
| 12 | |
| 13 | /// Apply pending migrations, or explain what to run by hand. |
| 14 | /// |
| 15 | /// The error names the database and the command that closes the gap, because |
| 16 | /// the failure a caller sees otherwise is a missing column with no context. |
| 17 | |
| 18 | run_migrations.map_err |
| 19 | format! |
| 20 | "could not migrate {path}: {e}\n\ |
| 21 | go-mcp will not serve a database whose schema it does not match.\n\ |
| 22 | Close GoingsOn, back the file up, and run:\n \ |
| 23 | cargo run -p goingson-db-sqlite --example migrate -- {path}" |
| 24 | path = db_path.display |
| 25 | ) |
| 26 | |
| 27 | |
| 28 |