Skip to content

JSON->SQLite one-time migration reruns on channel-specific DBs #16885

@vereis

Description

@vereis

Bug

The JSON->SQLite startup migration can rerun on every launch for non-latest channels (for example local/dev builds).

Reproduction

  1. Run OpenCode on a non-latest channel where the DB path is channel-specific (for example opencode-local.db)
  2. Keep legacy JSON storage files under ~/.local/share/opencode/storage/
  3. Start opencode twice

Actual

The startup banner "Performing one time database migration" appears on every launch and rescans/reimports JSON storage each time.

image

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.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions