Skip to content

fix(kanban): SCHEMA_SQL CREATE INDEX on session_id fails when upgrading from older kanban.db #28554

@kungunier

Description

@kungunier

Bug

When upgrading Hermes from a version that predates the session_id column to v0.14.0, the kanban dispatcher and dashboard fail with:

sqlite3.OperationalError: no such column: session_id
  File "hermes_cli/kanban_db.py", line 1012, in connect
    conn.executescript(SCHEMA_SQL)

The Kanban board in the web dashboard shows "Failed to load Kanban board: 500: Internal Server Error".

Root Cause

SCHEMA_SQL (line 808) contains:

CREATE TABLE IF NOT EXISTS tasks (...);
CREATE INDEX IF NOT EXISTS idx_tasks_session_id ON tasks(session_id);  -- line 868

For an existing kanban.db created by an older version, CREATE TABLE IF NOT EXISTS is a no-op (table already exists, old schema without session_id). But the CREATE INDEX on the next line references session_id which doesn't exist yet — this runs before _migrate_add_optional_columns() at line 1013, so the migration never gets a chance to add the column.

Steps to Reproduce

  1. Install an older version of Hermes (before session_id was added to kanban schema)
  2. Run hermes dashboard or anything that triggers kanban.db creation
  3. Upgrade to v0.14.0
  4. Run hermes dashboard → Kanban tab shows 500 error

Workaround

Delete the old kanban.db and let it regenerate:

rm ~/.hermes/kanban.db
hermes dashboard --stop
hermes dashboard

Proposed Fix

Option A: Move the CREATE INDEX IF NOT EXISTS idx_tasks_session_id and idx_tasks_model_override statements from SCHEMA_SQL into _migrate_add_optional_columns(), after the corresponding ALTER TABLE ADD COLUMN calls.

Option B: Wrap the index creation in a check for the column's existence:

if "session_id" in cols:
    conn.execute("CREATE INDEX IF NOT EXISTS idx_tasks_session_id ON tasks(session_id)")

Environment

  • Hermes v0.14.0 (updated from a pre-kanban v2 version)
  • WSL2 / Ubuntu
  • Node v22.22.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/pluginsPlugin system and bundled pluginstype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions