fix(kanban): create additive indexes after migrations#28602
Conversation
|
Thanks for the pointer. Agreed this overlaps with #28461/#28597 around #28464. This draft is intentionally the broader additive-index coverage path: it keeps the migration ordering fix for all optional columns that later indexes may reference (tenant, idempotency_key, session_id, run_id) rather than only the currently failing pair.\n\nHappy to keep this as draft while maintainers choose the preferred direction, close it in favor of another PR if that lands first, or rework it into supplemental regression coverage for the broader optional-index set. |
|
Thanks @verybigdog — closing as duplicate of #28781, which combined all six community PRs that hit this bug on 2026-05-19 into one salvage (merged in 7552e0f). You correctly diagnosed the SCHEMA_SQL-before-migration ordering issue. The salvage extends coverage to all four additive-column indexes ( |
Summary
Fixes Kanban DB initialization for legacy boards whose existing
tasks/task_eventstables predate additive columns that now have indexes.connect()runsSCHEMA_SQLbefore_migrate_add_optional_columns(). BecauseCREATE TABLE IF NOT EXISTSdoes not add missing columns to an existing table, anyCREATE INDEXinSCHEMA_SQLthat references an additive column can fail before the migration has a chance to add that column.This moves all currently indexed additive-column indexes out of
SCHEMA_SQLand creates them after the additive migration guarantees the columns exist:tasks.tenant/idx_tasks_tenanttasks.idempotency_key/idx_tasks_idempotencytasks.session_id/idx_tasks_session_idtask_events.run_id/idx_events_runRelationship to #28461
This intentionally overlaps with #28461, which fixes the same ordering class for
session_idandrun_id. This PR covers the broader additive-index set (tenant,idempotency_key,session_id, andrun_id) and adds a regression test with a legacy DB missing all four indexed additive columns.If maintainers prefer #28461 as the landing path, this can be closed or used as supplemental regression coverage / patch guidance.
Test Plan
python -m py_compile hermes_cli/kanban_db.py tests/hermes_cli/test_kanban_db_init.pypython -m pytest tests/hermes_cli/test_kanban_db_init.py -q -o addopts= --tb=shortgit diff --check