GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(opencode): DB migrating on every run for non-latest channels by bew · Pull Request #21056 · anomalyco/opencode

Conversation

@bew

@bew bew commented Apr 4, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Closes #21057
Closes #16885
Replaces #16884

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This PR fixes DB migration that was running on every start of opencode when installed from nixpkgs.
The nix package in nixpkgs sets OPENCODE_CHANNEL = "stable", which makes the DB have the name opencode-stable.db instead of opencode.db that the marker implied.

👉 Using the actual database path which already takes the OPENCODE_CHANNEL into account fixes the problem.

(change done manually, zero AI involved)

How did you verify your code works?

Yes, locally.

Screenshots / recordings

image The first run is from `main`, the second is with this PR.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jaredmontoya, blake-hamm, Lajdre, kirelagin, Kirottu, eberkut, georgefst, mmonfox, frederikmillingpytlick, and fveracoechea reacted with thumbs up emoji
All reactions
  • 👍 10 reactions
@github-actions github-actions Bot added the needs:issue label Apr 4, 2026
@github-actions

github-actions Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 4, 2026
This was referenced Apr 4, 2026
opencode: loosing sessions NixOS/nixpkgs#503765
Closed
DB migrating on every run when OPENCODE_CHANNEL is e.g. 'stable' (like the Nix package in nixpkgs) #21057
Closed
@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 4, 2026
@github-actions

github-actions Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bew
bew force-pushed the fix-repeated-migration branch from 5defc3f to 400fd62 Compare April 5, 2026 00:02
@bew bew changed the title fix: DB migrating on every run when OPENCODE_CHANNEL is e.g. 'stable' fix: DB migrating on every run for non-latest channels Apr 5, 2026
@bew bew mentioned this pull request Apr 5, 2026
JSON->SQLite one-time migration reruns on channel-specific DBs #16885
Closed
@JackLuguibin JackLuguibin mentioned this pull request Apr 5, 2026
📊 AI CLI 工具社区动态日报 2026-04-05 JackLuguibin/big_model_radar#1
Open
@bew

bew commented Apr 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

The failing test / unit (linux) (pull_request) pipeline seems to be for another reason 🤔

1 tests failed:
(fail) memory: abort controller leak > webfetch does not leak memory over many invocations [487.59ms]
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jaredmontoya

jaredmontoya commented Apr 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

@bew what if the test is flaky? Can you rebase and force push so that CI runs again?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bew
bew force-pushed the fix-repeated-migration branch from 400fd62 to 704fca0 Compare April 14, 2026 16:02
@bew

bew commented Apr 14, 2026

Copy link
Copy Markdown
Author

@bew what if the test is flaky? Can you rebase and force push so that CI runs again?

I rebased on dev, let me know if there is anything else I can do!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@blake-hamm

blake-hamm commented Apr 15, 2026

Copy link
Copy Markdown

This branch is working for me on nixos with. TY!

jaredmontoya and georgefst reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jaredmontoya

jaredmontoya commented Apr 15, 2026

Copy link
Copy Markdown

@thdxr can this PR get a review and hopefully get merged please?
It seems like tests fail for reasons unrelated to the changes in this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@opencode-agent
opencode-agent Bot force-pushed the dev branch from 2f2ed11 to 9f201d6 Compare April 16, 2026 21:55
@jhol

jhol commented Apr 24, 2026

Copy link
Copy Markdown

I ported this patch to 1.14.19 - the version I have via nixpkgs. It fixes the issue for me.

jaredmontoya and bew reacted with thumbs up emoji blake-hamm reacted with eyes emoji
All reactions
  • 👍 2 reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bew
bew force-pushed the fix-repeated-migration branch 2 times, most recently from a36c166 to 62e338e Compare April 24, 2026 19:30
@bew

bew commented Apr 24, 2026

Copy link
Copy Markdown
Author

I rebased on latest dev branch, which changed a few import paths.
Also added a proper commit description for this fix.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gigamonster256 gigamonster256 mentioned this pull request Apr 24, 2026
feat(nix): add opencode-electron derivation #16163
Merged
3 of 6 tasks
@bew
bew force-pushed the fix-repeated-migration branch from 62e338e to cd39d93 Compare May 15, 2026 01:29
@bew

bew commented May 15, 2026

Copy link
Copy Markdown
Author

Hello, I rebased on latest dev branch, any way to actually get this merged?

jaredmontoya reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jaredmontoya

jaredmontoya commented May 15, 2026

Copy link
Copy Markdown

@simonklee @thdxr @adamdotdevin @Hona @Brendonovich @nexxeln anyone?
Don't let this simple PR rot here even longer than 40 days for no reason please.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bew
bew force-pushed the fix-repeated-migration branch from cd39d93 to ef217e9 Compare May 19, 2026 16:36
@pwiens

pwiens commented May 20, 2026

Copy link
Copy Markdown

Heads up: this will silently break after rebase on fc34c7456 (#27615, May 15). That refactor renamed Database.Path (const) → Database.getPath() (function) and updated the four call sites in packages/opencode/src/cli/cmd/db.ts, but the marker in this PR isn't on main yet so it wasn't included.

Post-rebase, marker is undefined. fs.existsSync(undefined) returns false in both Bun 1.3.13 and Node 24, so !exists(undefined) is always true and the migration runs on every launch. The Bun build is transpile-only, so the missing namespace property doesn't surface at build time.

One-liner:

-    if (!(await Filesystem.exists(Database.Path))) {
+    if (!(await Filesystem.exists(Database.getPath()))) {

Cost is more than a noisy log line: JsonMigration.run re-scans the full JSON storage tree (6662 todos plus sessions/messages/parts in my case) on every launch. Not destructive thanks to onConflictDoNothing, but several seconds of disk IO at startup.

I hit this in a downstream fork that pulled in the same fix you have here, then rebased past fc34c7456.

jaredmontoya reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pwiens added a commit to pwiens/opencode that referenced this pull request May 20, 2026
@pwiens
Use channel-aware DB path as migration marker
168f2bb
The marker check in index.ts was hardcoded to Global.Path.data/opencode.db,
but the actual DB path is channel-aware (db.ts:getPath). On non-default
channels (local dev builds, named user channels), the real file is
opencode-<channel>.db, so the marker never exists and the 'one time'
migration runs on every launch.

Use Database.getPath() as the marker so it matches the channel-specific
filename that Database.Client() actually creates.

Note: upstream PR anomalyco#27615 (fc34c74) renamed Database.Path (const) to
Database.getPath() (function). The earlier version of this patch used
Database.Path and silently re-broke when rebased past the rename. Flagged
upstream at anomalyco#21056.
@bew
fix: DB migrating on every run when OPENCODE_CHANNEL is e.g. 'stable'
1f95617
@bew
bew force-pushed the fix-repeated-migration branch from ef217e9 to 1f95617 Compare May 20, 2026 17:07
@bew

bew commented May 20, 2026

Copy link
Copy Markdown
Author

Thanks @pwiens, I updated the PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bew bew changed the title fix: DB migrating on every run for non-latest channels fix(opencode): DB migrating on every run for non-latest channels May 23, 2026
@bew
Merge branch 'dev' into fix-repeated-migration
4b0b0a6
@mmonfox

mmonfox commented May 30, 2026

Copy link
Copy Markdown

I have the same issue, agent recommended `ln -s opencode-stable.db '~/.local/share/opencode/opencode.db' on my system and referenced this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bew

bew commented Jun 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

Hello everyone!
In #30461 the json migration system was removed (first released in v1.16.0).
👉 So this PR is not needed anymore!

Xyz00777 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bew bew closed this Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

DB migrating on every run when OPENCODE_CHANNEL is e.g. 'stable' (like the Nix package in nixpkgs) JSON->SQLite one-time migration reruns on channel-specific DBs

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@bew @jaredmontoya @blake-hamm @jhol @pwiens @mmonfox
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.