GeezerVison is showing github.com — Drizzle migration name mismatch causes startup crash on upgrade to v1.2.21 · Issue #16506 · anomalyco/opencode
Drizzle migration name mismatch causes startup crash on upgrade to v1.2.21 #16506Labels coreAnything pertaining to core functionality of the application (opencode server stuff) DescriptionDescription
After upgrading to v1.2.21, OpenCode crashes on startup:
Failed to run the query 'CREATE TABLE `project` (...)'
Root cause: Running a beta build (e.g. beta-20260306) before upgrading pollutes the shared __drizzle_migrations table — beta has migrations that stable does not. This confuses Drizzle into thinking earlier migrations were never applied, so it re-runs CREATE TABLE on tables that already exist.
Evidence: all 7 rows in __drizzle_migrations had correct timestamps but the same wrong name (20260303231226_add_workspace_fields).
Fix
Official fix by @thdxr (commit a965a06):
OPENCODE_SKIP_MIGRATIONS=1 bunx opencode-ai@dev
Run once to repair the database, then use OpenCode normally. Future beta builds use a separate database.
Steps to reproduce
- Run a beta build at some point (
bunx opencode-ai@beta)
- Upgrade to v1.2.21 stable
opencode crashes with CREATE TABLE project error
Environment
- macOS 15 (Apple Silicon), Ghostty
- Plugins: opencode-ralph-loop, antigravity-auth
Activityadded coreAnything pertaining to core functionality of the application (opencode server stuff) on Mar 7, 2026github-actions commented on Mar 7, 2026 This issue might be a duplicate of existing issues. Please check:
- [BUG] CREATE TABLE workspace migration silently recorded but not executed — crashes on v1.2.17 upgrade #16026: Similar Drizzle
__drizzle_migrations corruption causing startup crash on upgrade — also affected Apple Silicon macOS users with the same migration names (20260225215848_workspace, 20260303231226_add_workspace_fields). That issue was closed after being traced to a dev build with divergent migration timestamps, but the symptoms and affected table are identical. If your setup only ever used official releases, this may be a distinct bug worth tracking separately.
lazyalex616 commented on Mar 7, 2026 The bot flagged #16026 as a potential duplicate — turns out they are indeed related.
As @thdxr identified below, the root cause for both issues is the same: running a beta build pollutes the shared __drizzle_migrations table with migrations that stable releases don't have, which confuses Drizzle on the next stable upgrade.
My original analysis below assumed only official releases were involved, which was incorrect — I had forgotten that I ran a beta build at some point.
thdxr commented on Mar 7, 2026 did you ever run opencode beta? lazyalex616 commented on Mar 7, 2026
did you ever run opencode beta?
Wait, that's a good one. Yes, I did. Could that be the root cause? Cateds commented on Mar 7, 2026
did you ever run opencode beta?
I met the same problem. Once I launch the opencode v1.2.21, it says like:
❯ oc
Error: Unexpected error, check log file at /Users/cateds/.local/share/opencode/log/2026-03-07T210346.log for more details
Failed to run the query 'CREATE TABLE `project` (
`id` text PRIMARY KEY,
`worktree` text NOT NULL,
`vcs` text,
`name` text,
`icon_url` text,
`icon_color` text,
`time_created` integer NOT NULL,
`time_updated` integer NOT NULL,
`time_initialized` integer,
`sandboxes` text NOT NULL
);
'
And there was also a different sqlite error when I launch beta-20260306, and I switched to the non-beta version assuming it's just a bug. thdxr commented on Mar 7, 2026 yeah sorry about this - the beta has migrations that the main version does not which confuses drizzle. we started giving beta channels a different database so they don't conflict in the future
i can't immediately think of how to fix this easily. maybe i can add a flag that force skips migrations? flitzrrr commented on Mar 7, 2026 just met the same issue again with Version 1.2.21 (1.2.21) starting
#16026 was reported by me thdxr commented on Mar 7, 2026 a965a06 is being released but once it's there you can do
OPENCODE_SKIP_MIGRATIONS=1 bunx opencode-ai@dev and it should repair the database. from there should be able to use it normally
flitzrrr commented on Mar 7, 2026
MetadataMetadatacoreAnything pertaining to core functionality of the application (opencode server stuff) DevelopmentNo branches or pull requestsIssue actions
|