fix(core): migrate legacy local databases - #34188
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate Found:
Since this is an existing PR that tackles the same migration issue, you should check whether PR #31121 is still open/active or if it was closed/rejected, and understand why a new PR #34188 is being created to address the same problem. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #33887, closes #32361, closes #28013, closes #33828
Type of change
What does this PR do?
Fixes two legacy local database migration issues.
Older databases can have a Drizzle journal table named
__drizzle_migrationswith onlyid,hash, andcreated_at. The migration bridge expected anamecolumn, so startupfailed with
no such column: name. In the full TUI this looked like a blank hang because the screen was already cleared.Older sessions can also be attached to a previous project ID. Current code may resolve the same repo from its normalized git remote, while old rows used a root-commit project ID.
If there is no cached
.git/opencodeID, the app creates a new project row and/sessionsappears empty.This PR handles both cases during migration:
migrationtable from old Drizzle journal row count when migration names are unavailableGlobalBusto avoid a typedEventEmitter.emitoverride that fails current typecheckHow did you verify your code works?
bun test test/database-migration.test.ts -t "seeds unnamed Drizzle journal entries"bun test test/project/project.test.ts -t "migrates uncached root project data"bun typecheckfrompackages/corebun typecheckfrompackages/opencode/sessionsshows old sessions again.Screenshots / recordings
N/A
Checklist