You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Failed to run the query 'CREATE TABLE project" and logging issues #16678
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.
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.
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.
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
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
Activity
github-actions commentedon Mar 9, 2026
This issue might be a duplicate of existing issues. Please check:
The log file disappearing behavior you describe appears to be the same underlying bug reported in those issues. If the
CREATE TABLEproject`` error is a separate/new issue (possibly related to interrupted DB migration), it may be worth splitting into its own report.avarayr commentedon Mar 9, 2026
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:
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.
Smalldy commentedon Jul 2, 2026
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
arevno commentedon Jul 6, 2026
Wild that this showstopper is still open four months later, but it is.
Opencode is completely unusable suddenly:
github-actions commentedon Sep 5, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
DXXS commentedon Sep 6, 2026
just now happened to me too