Repository navigation
fix(core): support older previous-channel databases - #43142
Merged
Merged
Conversation
kitlangton
enabled auto-merge (squash)
August 18, 2026 00:36
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
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.
What
Make the previous-V2 database importer tolerate older
opencode-next.dbschemas whose optional project or session columns predate the current importer.Fixes #43139.
Fixes #41341.
Before / After
Before: The importer read
projectandsessionwithSELECT *into the current TypeScript row shapes. If the source database lacked a newer nullable column such asicon_url_override,fork_boundary, ortime_suspended, property access returnedundefined. Drizzle rendered that value as an empty SQL expression, producing statements likeVALUES (..., , ...)and failing migration withSQLiteError: near ",": syntax error.After: The importer inspects each source table and builds an explicit projection. Existing columns are selected normally, absent optional columns are projected as SQL
NULL, and absent required columns fail early with a compatibility error naming the table and columns. Historical field backfills, includingicon_url_overridefromicon_url, are preserved. The destination inserts therefore never receiveundefinedfor declared historical fields.How
packages/core/src/database/v1-migration.bun.tsdefines an exhaustive compatibility strategy for every previous-V2 project and session field. Adding a future field now requires declaring whether it is required, nullable, or copied from an older field.selectNextRowsreadspragma_table_info, synthesizes compatible source projections, and preserves session import ordering.packages/core/test/v1-migration.test.tscreates a real older-shape SQLite database, runs the importer, verifies missing fields arrive asNULL, and verifies the historical project icon backfill.Scope
This fixes the Core previous-V2 import path. It does not change client migration readiness or restored-session error handling.
Testing
bun run test ./test/v1-migration.test.tsfrompackages/core: 24 passedbun run testfrompackages/core: 1,842 passed, 16 skippedbun typecheckfrompackages/core: passed