Skip to content

Drizzle migration name mismatch causes startup crash on upgrade to v1.2.21 #16506

Closed

Description

@lazyalex616

Description

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

  1. Run a beta build at some point (bunx opencode-ai@beta)
  2. Upgrade to v1.2.21 stable
  3. opencode crashes with CREATE TABLE project error

Environment

  • macOS 15 (Apple Silicon), Ghostty
  • Plugins: opencode-ralph-loop, antigravity-auth

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 7, 2026
  2. github-actions commented on Mar 7, 2026

    @github-actions
    Contributor

    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.
  3. lazyalex616 commented on Mar 7, 2026

    @lazyalex616
    Author

    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.

  4. thdxr commented on Mar 7, 2026

    @thdxr
    Member

    did you ever run opencode beta?

  5. lazyalex616 commented on Mar 7, 2026

    @lazyalex616
    Author

    did you ever run opencode beta?

    Wait, that's a good one. Yes, I did. Could that be the root cause?

  6. Cateds commented on Mar 7, 2026

    @Cateds

    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.

  7. thdxr commented on Mar 7, 2026

    @thdxr
    Member

    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?

  8. flitzrrr commented on Mar 7, 2026

    @flitzrrr

    just met the same issue again with Version 1.2.21 (1.2.21) starting
    #16026 was reported by me

  9. thdxr commented on Mar 7, 2026

    @thdxr
    Member

    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

  10. flitzrrr commented on Mar 7, 2026

    @flitzrrr

    thanks!! fixed it!!

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions