fix(db): restore channel-aware path — ECS was opening wrong database file - #75
Merged
Conversation
… behavior The upstream sync (PR #72) simplified getPath() in db.ts to always return opencode.db, but packages/core/src/database/database.ts still uses a channel-suffixed path (opencode-local.db when InstallationChannel="local", which is the case on ECS where OPENCODE_CHANNEL is not bundled). The pre-PR72 db.ts also used a channel-aware path (getChannelPath). Losing the suffix meant db.ts opened a fresh opencode.db on ECS while all production data was in opencode-local.db, causing the drizzle SQL migration to fail with "ALTER TABLE session ADD metadata text" on a database with no session table. Fix: restore the channel-suffix logic (matching both old db.ts and database.ts) and also honour OPENCODE_DISABLE_CHANNEL_DB for parity with database.ts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
hoj-unleash
self-requested a review
August 19, 2026 04:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Root cause
The ECS deployment after PR #72/#73 was opening a fresh
opencode.dbwhile all production data lived inopencode-local.db. This caused the drizzle SQL migration to immediately crash with:Because the fresh
opencode.dbhad nosessiontable yet.Why this happened
The upstream sync (PR #72) simplified
getPath()indb.tsto always returnopencode.db:But
packages/core/src/database/database.tsuses a channel-suffixed path, and the pre-PR72db.tsalso used a channel-aware path. WhenOPENCODE_CHANNELis not bundled (which is the case on ECS, since the server runs from TypeScript source),InstallationChannel = "local"and the channel path isopencode-local.db.So in ECS:
db.tsopencode-local.db✓database.tsopencode-local.db✓db.ts(broken)opencode.db✗db.ts(fixed)opencode-local.db✓Fix
Restore the channel-suffix logic in
db.ts'sgetPath(), matching both the old behavior anddatabase.ts. Also addsOPENCODE_DISABLE_CHANNEL_DBsupport for parity withdatabase.ts.Verification
Tested with a production-accurate EFS database (20 old SQL migration records, full schema at
opencode-local.db):Server starts cleanly. PR #74's legacy migration seeding fix still runs correctly on top of this.
Next steps
Merge this PR, then trigger
deploy-collab.yml.