Repository navigation
server: V1 migration fails every startup with SQLiteError: no such column: path #54009
Description
Summary
The V1→V2 data migration fails on every server startup with SQLiteError: no such column: path while in the sessions phase. The migration marker never advances, so the import retries (and fails) on every subsequent start, surfacing a persistent "migration failed" notification in the TUI.
Environment
- opencode version: 2.0.25
- OS: Windows_NT 10.0.26300 (win32 x64)
- Terminal: Windows console (opencode opened from command line); no
$TERM/$TERM_PROGRAMset - Shell: cmd.exe / PowerShell
- Install/channel: latest
- Active plugins: none found in config
Reproduction
- Upgrade from V1 to V2 (config was in V1 format; config migration succeeded and produced
opencode.json.v1.bak). - Start the V2 server. Normal schema migrations complete; the background V1 data migration then fails during the
sessionsphase. - Restart opencode. The migration resumes at
sessions, fails the same way, and the TUI shows a "migration failed" notification on every startup.
Observed in ~/.local/share/opencode/log/opencode.log (repeats for every server run since 2026-10-06):
level=ERROR message="V1 migration failed" cause="Cause([Die(SQLiteError: no such column: path)])" role=server
Expected Behavior
- The
sessionsphase of the V1 import completes (or skips cleanly when there is nothing left to import). - The
migration.v1-v2marker advances/ completes so the import is not retried on every startup. - Missing columns on legacy tables should be projected as NULL or handled with a named compatibility error, not an unhandled SQLite error.
Actual Behavior
-
The migration is durably stuck at
{"phase":"sessions"}:SELECT value FROM kv WHERE key = 'migration.v1-v2'; -- {"phase":"sessions"}
-
The legacy
sessiontable inopencode.dbhas nopathcolumn (it hasdirectory; onlysession_v2haspath), yet the sessions-phase importer referencespath:.schema session CREATE TABLE session ( id TEXT PRIMARY KEY, project_id TEXT NOT NULL, parent_id TEXT, slug TEXT NOT NULL, directory TEXT NOT NULL, title TEXT NOT NULL, version TEXT NOT NULL, share_url TEXT, ... workspace_id TEXT, ... ); -- no `path` column
Note: schema migration
20260428004200_add_session_pathis recorded as completed in themigrationtable, but the legacysessiontable still lackspath. -
Row counts in the affected database:
session=1,session_v2=24,message=1,part=1,session_message=108,project=8 — i.e. most sessions already imported; one legacy row appears to be the one that cannot complete. -
Every startup: schema migrations complete, then
V1 migration failed ... no such column: path, TUI notification shown.
Additional Context
- Timeline: database bootstrapped cleanly on 2026-10-04 (48 schema migrations OK);
V1 migration failedentries begin 2026-10-06 after updating; on 2026-10-08 migration20261007190000_azure_cli_external_credentialran fine, then the V1 migration failed again. Consistent 100% reproduction on every server start since. - Config migration itself succeeded (global config converted to native V2,
.v1.bakretained). Models, credentials, MCP servers, and sessions all work; impact is the recurring error notification and the never-completing import. - Same failure family as core: V1 migration fails against older previous-channel database schemas #43139 (importer assumes columns the source table lacks) but a distinct error: theirs is
near ",": syntax errorfromundefinedinterpolation; here it isno such column: pathreferencing a column absent from the legacysessiontable. Related: V1→V2 session migration fails when previous channel DB lacks fork_boundary #41341, server: V1 migration fails with SQLiteError near ',' on apostrophes in legacy message data #41869, core: V1 migration fails on every startup with SQLiteError: near ",": syntax error #45829, and v2: sessions with path=NULL (around v1's add_session_path schema change) are missing from project session lists #51144 / Upgrade to 1.17.x hides pre-existing sessions — new path column not back-filled during migration #35750 for theadd_session_pathhistory. - No workaround applied: did not modify the database or the
migration.v1-v2marker, per troubleshooting guidance.
Activity
opencode-agent commentedon Oct 8, 2026
Thanks for the detailed report. I reproduced this on 2.0.25. The setup was a fresh V2 database plus a V1-format legacy
sessiontable without apathcolumn and themigration.v1-v2marker set to{"phase":"sessions"}. Every server start then logsV1 migration failed ... SQLiteError: no such column: path, and the marker never advances.The sessions-phase importer reads
pathdirectly from the legacysessiontable, so a legacy table without that column makes the import fail. It still happens on the latestv2branch (8059cdcb), run from source. The script below reproduces it with an isolated data directory.Reproduction script (repro.sh)
Run it:
bash repro.sh