Skip to content

fix(core): support older previous-channel databases - #43142

Merged
kitlangton merged 2 commits into
v2from
fix-next-migration
Aug 18, 2026
Merged

kitlangton merged 2 commits into
v2from
fix-next-migration

Conversation

@kitlangton

@kitlangton kitlangton commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Make the previous-V2 database importer tolerate older opencode-next.db schemas whose optional project or session columns predate the current importer.

Fixes #43139.
Fixes #41341.

Before / After

Before: The importer read project and session with SELECT * into the current TypeScript row shapes. If the source database lacked a newer nullable column such as icon_url_override, fork_boundary, or time_suspended, property access returned undefined. Drizzle rendered that value as an empty SQL expression, producing statements like VALUES (..., , ...) and failing migration with SQLiteError: 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, including icon_url_override from icon_url, are preserved. The destination inserts therefore never receive undefined for declared historical fields.

How

  • packages/core/src/database/v1-migration.bun.ts defines 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.
  • selectNextRows reads pragma_table_info, synthesizes compatible source projections, and preserves session import ordering.
  • packages/core/test/v1-migration.test.ts creates a real older-shape SQLite database, runs the importer, verifies missing fields arrive as NULL, 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.ts from packages/core: 24 passed
  • bun run test from packages/core: 1,842 passed, 16 skipped
  • bun typecheck from packages/core: passed
  • Repository pre-push typecheck: 33 tasks passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant