Skip to content

migrate: V1-era session exists only in legacy table, invisible to V2 clients #50980

Closed as duplicate

Description

@stevenshack

Summary

After upgrading from opencode 1.x to 2.0.15, a session created by V1 minutes
before the upgrade exists in the legacy session table but was never carried
into session_v2 (the live store). It is invisible to the TUI,
opencode session list, and the API — apparent data loss for the user.

Environment

  • opencode version: 2.0.15 (upgrade V1 -> V2 performed 2026-09-23)
  • OS: Linux 6.12.107+deb13-amd64 (Debian 13)
  • Terminal: xterm-256color, truecolor
  • Shell: fish
  • Install/channel: latest
  • Active plugins: none configured

Reproduction

  1. Run opencode 1.x and create a session (this one was created ~11 minutes
    before the V2 upgrade; V1 wrote it to the legacy session table only).
  2. Upgrade to opencode 2.0.15 and let the first V2 server start apply DB
    migrations.
  3. Run opencode session list in the session's directory — the session does
    not appear.
  4. Inspect the database read-only:
    • SELECT id FROM session WHERE id = 'ses_f304ef2b…'; → 1 row (legacy)
    • SELECT id FROM session_v2 WHERE id = 'ses_f304ef2b…'; → 0 rows

Expected Behavior

The V1→V2 data migration should carry every session from the legacy
session/message/part tables into session_v2 (or V2 clients should fall
back to the legacy table for sessions missing from the live store).

Actual Behavior

The session is present in the legacy projection only. No V2 client surface
shows it. It could only be recovered by manually rebuilding an export-format
JSON ({"info": …, "messages": …}) from the legacy tables and running
opencode session import --directory <dir>.

Additional Context

  • The first V2 server start did apply migrations (~54 rows in the migration
    table), so the gap is specifically this last-minute V1 write.
  • Verified workaround: manual reconstruction + re-import; all 20 messages /
    64 parts recovered intact.

Activity

  1. rekram1-node commented on Oct 21, 2026

    @rekram1-node
    Contributor

    Same root cause as #50130: once the V1→V2 migration is marked complete (most likely by an earlier V2 run on this database), V1 sessions written afterwards are not imported. Tracking there.

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

Metadata

Metadata

Assignees

No one assigned

    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