GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — "Failed to run the query 'CREATE TABLE `project`" and logging issues · Issue #16678 · anomalyco/opencode

"Failed to run the query 'CREATE TABLE project" and logging issues #16678

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
"Failed to run the query 'CREATE TABLE project" and logging issues#16678
Copy link
Assignees
rekram1-node

Description

@ycros
ycros
opened on Mar 9, 2026
Issue body actions

Description

Started opencode... didn't do anything, exited, ran opencode upgrade to check for updates... already on the latest. Tried to start opencode again, can't.

I'm going to guess that maybe I quit mid migration, but then perhaps it should be using a transaction or shouldn't let me /exit

Plugins

none

OpenCode version

1.2.22

Steps to reproduce

No response

Screenshot and/or share link

Error: Unexpected error, check log file at /home/ycros/.local/share/opencode/log/2026-03-09T024158.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
);

Okay so, secodary bug, if I look at the log I get this:

INFO  2026-03-09T02:42:19 +235ms service=default version=1.2.22 args=[] opencode
INFO  2026-03-09T02:42:19 +2ms service=default directory=/home/ycros/Dev/lgame2 creating instance
INFO  2026-03-09T02:42:19 +0ms service=project directory=/home/ycros/Dev/lgame2 fromDirectory
INFO  2026-03-09T02:42:19 +13ms service=db path=/home/ycros/.local/share/opencode/opencode.db opening database

Side bug:

But here's the thing, I tried to start opencode multiple times. So this probably isn't the actual relevant log. Where's that log? Gone.
If I run some other opencode command that log there also disappears and there's only a log with a newer timestamp? That seems pretty bad given that they're timestamped - why the hell is it erasing prior log files? In fact, I have no log files from the 4th, and I have been using opencode a bunch.

Operating System

Ubuntu 24.04

Terminal

ghostty

Reacted by smalldy
Reacted by smalldy

Activity

  1. ycros
    added
    bugSomething isn't working
    on Mar 9, 2026
  2. github-actions
    assigned
    rekram1-node
    on Mar 9, 2026
  3. github-actions
    added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 9, 2026
  4. github-actions commented on Mar 9, 2026

    @github-actions
    github-actionsBot
    on Mar 9, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of existing issues. Please check:

    • Log cleanup deletes newest log files instead of oldest (path-scurry reverse ordering) #14731: Log cleanup deletes newest log files instead of oldest (same symptom: recent log files disappear)
    • [bug] Log cleanup race condition deletes newest log file on repeated launches #16540: [bug] Log cleanup race condition deletes newest log file on repeated launches (same root cause, was closed/fixed)

    The log file disappearing behavior you describe appears to be the same underlying bug reported in those issues. If the CREATE TABLE project`` error is a separate/new issue (possibly related to interrupted DB migration), it may be worth splitting into its own report.

  5. avarayr commented on Mar 9, 2026

    @avarayr
    avarayr
    on Mar 9, 2026
    More actions

    Same issue, opencode doesnt launch after update to 1.2.24 in my case

    Fixed with Claude Code locally, see if this helps you


    Claude Code's output

    Root Cause: The Drizzle ORM update in commit 5e699c9 (chore(storage): update drizzle and channel db handling) changed migration tracking from hash-based to name-based. The
    __drizzle_migrations table gained a name column, but existing records from older versions don't have entries that the new Drizzle recognizes. So migrate() thinks the initial migration
    (20260127222353_familiar_lady_ursula) was never applied and tries to re-run CREATE TABLE project — which fails because the table already exists.

    Workaround:

      sqlite3 ~/.local/share/opencode/opencode.db "INSERT OR IGNORE INTO __drizzle_migrations (hash, created_at, name) SELECT '', 0, v.name FROM (SELECT '20260127222353_familiar_lady_ursula'
       AS name UNION ALL SELECT '20260211171708_add_project_commands' UNION ALL SELECT '20260213144116_wakeful_the_professor' UNION ALL SELECT '20260225215848_workspace' UNION ALL SELECT
      '20260227213759_add_session_workspace_id' UNION ALL SELECT '20260303231226_add_workspace_fields') v WHERE v.name NOT IN (SELECT name FROM __drizzle_migrations);"

    This backfills the missing migration journal entries so Drizzle knows they were already applied.

    Suggested fix for maintainers: Make migration SQL idempotent at runtime in db.ts by replacing CREATE TABLE → CREATE TABLE IF NOT EXISTS and CREATE INDEX → CREATE INDEX IF NOT EXISTS
    before passing entries to migrate(). This would make upgrades resilient to journal corruption or format changes.

  6. thdxr
    removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  7. Smalldy commented on Jul 2, 2026

    @Smalldy
    Smalldy
    on Jul 2, 2026
    More actions

    The high probability of reproducing this issue is unacceptable to the point where it cannot be used normally. It is an extremely serious problem, and we hope it can be resolved

  8. arevno commented on Jul 6, 2026

    @arevno
    arevno
    on Jul 6, 2026
    More actions

    Wild that this showstopper is still open four months later, but it is.

    Opencode is completely unusable suddenly:

    ERROR 2026-07-06T21:10:47 +1ms service=server ref=err_898eaf61 error=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
    );
    ' Caused by: table project already exists cause=DrizzleError: 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
    );
    '
        at run (/$bunfs/root/chunk-8wk79pqa.js:716:13211)
        at migrate (/$bunfs/root/chunk-8wk79pqa.js:716:518)
        at ic (/$bunfs/root/chunk-8wk79pqa.js:716:22500)
        at <anonymous> (/$bunfs/root/chunk-8wk79pqa.js:716:34046)
        at nc (/$bunfs/root/chunk-8wk79pqa.js:716:34333)
        at Project.fromDirectory (/$bunfs/root/chunk-e19ca6x8.js:2:1313)
        at Project.fromDirectory (definition) (/$bunfs/root/chunk-bmkbf576.js:210:4106)
        at InstanceStore.boot (/$bunfs/root/chunk-e19ca6x8.js:2:1475)
        at InstanceStore.load (/$bunfs/root/chunk-e19ca6x8.js:2:2636) {
      [cause]: SQLiteError: table project already exists
          at prepare (unknown)
          at prepare (bun:sqlite:345:37)
          at prepareQuery (/$bunfs/root/chunk-8wk79pqa.js:716:14283)
          at run (/$bunfs/root/chunk-8wk79pqa.js:716:13167)
          at migrate (/$bunfs/root/chunk-8wk79pqa.js:716:518)
          at ic (/$bunfs/root/chunk-8wk79pqa.js:716:22500)
          at <anonymous> (/$bunfs/root/chunk-8wk79pqa.js:716:34046)
          at nc (/$bunfs/root/chunk-8wk79pqa.js:716:34333)
    } failed
    
  9. github-actions commented on Sep 5, 2026

    @github-actions
    github-actionsBot
    on Sep 5, 2026 – with GitHub Actions
    Contributor
    More actions

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  10. github-actions
    closed this as not plannedon Sep 5, 2026
  11. DXXS commented on Sep 6, 2026

    @DXXS
    DXXS
    on Sep 6, 2026
    More actions

    just now happened to me too

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

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.