-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Description
Bug
The JSON->SQLite startup migration can rerun on every launch for non-latest channels (for example local/dev builds).
Reproduction
- Run OpenCode on a non-
latestchannel where the DB path is channel-specific (for exampleopencode-local.db) - Keep legacy JSON storage files under
~/.local/share/opencode/storage/ - Start
opencodetwice
Actual
The startup banner "Performing one time database migration" appears on every launch and rescans/reimports JSON storage each time.
Expected
Migration should run once and skip on subsequent launches.
Root cause
The startup gate checks for ~/.local/share/opencode/opencode.db, but non-latest channels can use DB names like opencode-local.db, so the gate never flips to true.
Why not just check channel-specific DB names?
Checking channel DB filenames only addresses the rerun failure mode. It does not address the existing skip failure mode where a DB file can exist from prior schema migrations even if JSON->SQLite import has never completed. In that case, a DB-existence gate can incorrectly skip migration and orphan legacy JSON data.
Suggested fix
Use a dedicated migration completion marker (or migration table entry) instead of checking for a specific DB filename.