Skip to content

bug: migration 20260604172448 deletes entire event log for all users on next release #30963

Description

@Flare576

Description

PR #30785 merged yesterday includes a migration that runs DELETE FROM event and UPDATE session SET workspace_id = NULL unconditionally. I hit this when I synced to dev today.

After digging deeper, the actual impact is more nuanced than my initial report — worth updating.

What the migration actually does

  • DELETE FROM session_input — derived data, fine
  • DELETE FROM session_message — V2 projection layer, also fine if it gets re-projected
  • DELETE FROM event — this is the one I was worried about, but see below
  • UPDATE session SET workspace_id = NULL — this is the real user-visible problem

What message vs session_message actually are

There are two separate tables: message (12,000+ rows, intact, going back to March) and session_message (the V2 projection). The migration only touched session_message and event — the message table with actual conversation content was never deleted. The data is fine.

The actual bug: /sessions shows nothing

Session.list() in session.ts filters by workspace_id when one is provided. The migration set every session's workspace_id to NULL. So when the TUI calls the session list with a workspaceID, zero rows match — not because sessions are gone, but because the join condition can't match NULL.

The sessions are all there. They're just invisible to any workspace-scoped query.

My read on what's happening

The DELETE FROM event suggests the V2 event schema changed incompatibly with existing rows. The workspace_id = NULL suggests workspace association is being reworked. This looks like an in-progress migration for a feature that isn't fully wired yet — not a data-loss issue, but it does mean dev branch users will see an empty session list after updating until the workspace re-association logic lands.

Steps to reproduce

  1. Existing OpenCode installation with session history
  2. Update to a build containing 20260604172448_event_sourced_session_input
  3. Launch OpenCode — migration runs automatically
  4. Open /sessions — empty, even though SELECT COUNT(*) FROM session returns 352

OpenCode version

Latest dev (post #30785)

Operating System

macOS 15.x

Terminal

Ghostty

Activity

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