[PR #13699] fix: run JSON session migration for incremental upgrades #14780

Open
opened 2026-02-16 18:19:32 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13699

State: open
Merged: No


Summary

Fixes #13654.

The JSON->SQLite migration gate currently checks for opencode.db. That fails for incremental upgrades because the DB can exist from earlier schema migrations, so legacy JSON sessions never get imported.

This PR switches the gate to a dedicated migration marker:

  • run migration when storage/ exists and json-sqlite-migration-complete is missing
  • write the marker after migration completes
  • keep migration logic unchanged otherwise

Why this fixes it

Users who already have opencode.db but still have legacy JSON session files will now run the import once and recover old sessions.

Testing

  • ~/.bun/bin/bun test test/storage/json-migration.test.ts
  • ~/.bun/bin/bun test test/storage/json-migration.test.ts --coverage
  • Added tests for migration gating behavior:
    • storage exists + marker missing -> runs
    • marker exists -> skips
    • storage missing -> skips
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13699 **State:** open **Merged:** No --- ## Summary Fixes #13654. The JSON->SQLite migration gate currently checks for `opencode.db`. That fails for incremental upgrades because the DB can exist from earlier schema migrations, so legacy JSON sessions never get imported. This PR switches the gate to a dedicated migration marker: - run migration when `storage/` exists and `json-sqlite-migration-complete` is missing - write the marker after migration completes - keep migration logic unchanged otherwise ## Why this fixes it Users who already have `opencode.db` but still have legacy JSON session files will now run the import once and recover old sessions. ## Testing - `~/.bun/bin/bun test test/storage/json-migration.test.ts` - `~/.bun/bin/bun test test/storage/json-migration.test.ts --coverage` - Added tests for migration gating behavior: - storage exists + marker missing -> runs - marker exists -> skips - storage missing -> skips
yindo added the pull-request label 2026-02-16 18:19:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14780