-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Title: Add schema versioning and migrations for the SQLite runtime store
Type: refactor
Severity: high
Area: runtime database / persistence architecture
Description:
The SQLite runtime store now underpins jobs, logs, reports, history, customer history, maintenance status, and export. Despite that central role, the store has no explicit schema versioning or migration framework. It initializes tables opportunistically with CREATE TABLE IF NOT EXISTS, but there is no PRAGMA user_version, migration registry, or startup compatibility check. Future schema changes will be forced into ad hoc conditional SQL and risk silent incompatibilities for installed databases.
Evidence:
/Users/techmore/projects/NmapUI/nmapui/runtime_db.pydefinesSCHEMA_STATEMENTSand runs them ininitialize()but does not track a runtime DB schema version- the runtime DB is now used widely across
/Users/techmore/projects/NmapUI/nmapui/handlers/routes.py,/Users/techmore/projects/NmapUI/nmapui/handlers/connections.py, and report/history flows, which raises the cost of incompatible schema drift - migration/export behavior in
/Users/techmore/projects/NmapUI/build.shand/Users/techmore/projects/NmapUI/scripts/backfill_runtime_store.pyassumes the DB can be copied forward without explicit version negotiation
Proposed Fix:
Introduce versioned runtime DB migrations with explicit startup enforcement.
Implementation Notes:
- Use
PRAGMA user_versionor a dedicated metadata table as the single schema version source - Add ordered migration functions and tests for upgrade paths
- Fail clearly on unsupported future versions instead of implicitly operating on unknown schemas
- Add an admin command to inspect and repair runtime DB versions
Related Issues: