Skip to content

Migration 85 relabels a real OpenCode 2 host's rows to opencode (tags and session state orphaned on upgrade to 0.42.6) #475

Closed

Description

@qoole

Short description

Migration 85 relabels a real OpenCode 2 host's opencode2 rows to opencode, so an existing OpenCode 2 install loses its tags and session state on upgrade to 0.42.6.

What happened?

Migration 85 ("relabel OpenCode 1.x mis-tagged opencode2 session rows") rewrites every opencode2 row to opencode. The 0.42.6 notes explain why: "No released Magic Context has run on a real OpenCode 2 host against the shared database, so those rows are the v1 mislabel above."

That isn't true for everyone. I have run 0.42.5 on an OpenCode 2.0.7 server since 2026-09-15. It was locally patched, because stock 0.42.5 cancelled every turn on 2.0.7 (the context.catalog issue fixed in 0.42.6). It ran against its own context store. So its rows are correctly labelled opencode2.

What migration 85 does to that store, measured on a copy before upgrading:

before (0.42.5, schema 84) after first 0.42.6 boot (schema 85)
tags opencode2 × 2788 opencode × 2788, opencode2 × 1 (new)
session_meta opencode2 × 32 opencode × 32

After the migration, the OpenCode 2 host keeps writing under opencode2, so all existing tags and session metadata become invisible to it. In a large session that includes every earlier drop decision.

I avoided it by inserting a schema_migrations row for version 85 by hand before upgrading, so the runner skips it. That works for me but isn't something users should have to do.

I'm filing this as an issue, not a PR, because the fix needs a decision I don't think is mine to make:

  • Migration 85 has already shipped and run. Any OpenCode 2 user who upgraded has already been relabelled, so a repair for them is needed as well as a guard for future runs.
  • The migration can't tell a 1.x mislabel from a genuine 2.x row on its own. One option: for each opencode2 session, check whether the OpenCode store it belongs to has that session in session_v2, which only an OpenCode 2 host writes, and relabel only when it doesn't.

Environment

  • Plugin version: 0.42.6 (upgrading from a locally patched 0.42.5)
  • OpenCode version: 2.0.7 (@opencode/cli), server mode, store migrated from 1.18.x
  • Platform: linux x64

Related PRs from the same upgrade:

Without both fixes, 0.42.6 can't be used on that host at all, which is how the table above came from a test copy rather than from production.

Activity

  1. magic-alfonso commented on Sep 24, 2026

    @magic-alfonso

    Fixed in 0.43.0, released today. The migration that relabelled every opencode2 row as opencode is now inert, and a later migration restores each session's label from the store's own activity, so a real OpenCode 2 install is labelled correctly again. If you still see this on 0.43.0, reopen and I'll look again.

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