Skip to content

History sessions lost after update - database file changed from opencode.db to opencode-prod.db #21790

Closed

Description

@zeroone001

Description

After updating opencode today, all my previous conversation history disappeared. The UI shows no sessions from before the update.

Root Cause

The new version switched the database file from opencode.db to opencode-prod.db, but did not migrate existing data:

File Sessions Messages Size
opencode.db (old) 45 2139 27MB
opencode-prod.db (new) 3 13 147KB

The old data is still intact in opencode.db, but the new version only reads from opencode-prod.db.

Expected Behavior

Existing session history should be automatically migrated to the new database file during the upgrade process, or the new version should continue reading from the existing database.

Workaround

Manually merge the old data into the new database:

# Backup first
cp ~/.local/share/opencode/opencode-prod.db ~/.local/share/opencode/opencode-prod.db.bak

# Merge old data (skip duplicates)
sqlite3 ~/.local/share/opencode/opencode-prod.db "
ATTACH DATABASE '$HOME/.local/share/opencode/opencode.db' AS old;
INSERT OR IGNORE INTO main.project SELECT * FROM old.project;
INSERT OR IGNORE INTO main.workspace SELECT * FROM old.workspace;
INSERT OR IGNORE INTO main.session SELECT * FROM old.session;
INSERT OR IGNORE INTO main.message SELECT * FROM old.message;
INSERT OR IGNORE INTO main.part SELECT * FROM old.part;
INSERT OR IGNORE INTO main.todo SELECT * FROM old.todo;
INSERT OR IGNORE INTO main.session_share SELECT * FROM old.session_share;
INSERT OR IGNORE INTO main.permission SELECT * FROM old.permission;
INSERT OR IGNORE INTO main.event_sequence SELECT * FROM old.event_sequence;
INSERT OR IGNORE INTO main.event SELECT * FROM old.event;
DETACH DATABASE old;
"

Suggested Fix

Add an automatic migration step on startup: if opencode-prod.db is empty or newly created and opencode.db exists with data, automatically merge all records into the new database.

Environment

  • OS: macOS (Darwin)
  • opencode version: latest (auto-updated)
  • Data directory: ~/.local/share/opencode/

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

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

    @github-actions
    Contributor

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

    If your issue is the same as one of these, it may already be addressed or tracked there.

  3. thdxr commented on Apr 10, 2026

    @thdxr
    Member

    hmm this is weird here is the logic

      export function getChannelPath() {
        if (["latest", "beta"].includes(CHANNEL) || Flag.OPENCODE_DISABLE_CHANNEL_DB)
          return path.join(Global.Path.data, "opencode.db")
        const safe = CHANNEL.replace(/[^a-zA-Z0-9._-]/g, "-")
        return path.join(Global.Path.data, `opencode-${safe}.db`)
      }
    

    are you running something that potentially is built differently?

  4. thdxr commented on Apr 10, 2026

    @thdxr
    Member

    oh wait is this the desktop app? are you using the electron version?

  5. thdxr commented on Apr 10, 2026

    @thdxr
    Member

    we're fixing this - electron version isn't meant to be used yet sorry about that

  6. assigned and unassigned on Apr 26, 2026
  7. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
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