Skip to content

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

Closed as not planned

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.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 10, 2026
  2. github-actions commented on Mar 10, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  3. alteredoxide commented on Mar 16, 2026

    @alteredoxide

    I experienced precisely this issue, with my file being named opencode-stable.db. My workaround was to use a symlink: ln -s ~/.local/share/opencode/opencode-stable.db ~/.local/share/opencode/opencode.db

  4. bew commented on Apr 5, 2026

    @bew

    note: I've opened #21056 with an alternate fix (compared to #16884) that use the real DB path as the marker path.

  5. xiantang commented on Apr 5, 2026

    @xiantang
    Contributor

    for me is ln -s ~/.local/share/opencode/opencode-local.db ~/.local/share/opencode/opencode.db
    pls check what is under ~/.local/share/opencode/ before u do it

    I experienced precisely this issue, with my file being named opencode-stable.db. My workaround was to use a symlink: ln -s ~/.local/share/opencode/opencode-stable.db ~/.local/share/opencode/opencode.db

  6. kirelagin commented on Apr 25, 2026

    @kirelagin

    This is also a problem when building from the flake in the upstream repository (i.e. this one), since it sets channel to local.

  7. assigned and unassigned on Apr 26, 2026
  8. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  9. 0fflineuser commented on May 31, 2026

    @0fflineuser

    I also got the issue with one NixOS after upgrading from 25.11 to 26.05.

  10. bew commented on May 31, 2026

    @bew

    I also got the issue with one NixOS after upgrading from 25.11 to 26.05.

    Doesn't surprise me since my PR isn't merged yet 😬
    See #21056

  11. bew commented on Jun 13, 2026

    @bew

    Hello everyone!
    In #30461 the json migration system was removed (first released in v1.16.0).
    👉 So this issue can be closed ¯\_(ツ)_/¯

  12. github-actions commented on Aug 12, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions