mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-29 06:31:32 +00:00
fix(kanban): make legacy task migration idempotent
(cherry picked from commit 293f1c3a7241b0117669e049d9aa746c9645ac90)
This commit is contained in:
parent
c30608cfbe
commit
0b547aea03
1 changed files with 8 additions and 5 deletions
|
|
@ -1057,6 +1057,14 @@ def _migrate_add_optional_columns(conn: sqlite3.Connection) -> None:
|
|||
"CREATE INDEX IF NOT EXISTS idx_tasks_idempotency "
|
||||
"ON tasks(idempotency_key)"
|
||||
)
|
||||
|
||||
# Refresh after early additive migrations above. Some existing DBs were
|
||||
# partially migrated in older releases and can already contain the later
|
||||
# columns (for example ``consecutive_failures``) even when this function's
|
||||
# initial snapshot did not. Re-snapshot here so the legacy-column migration
|
||||
# below is truly idempotent and never re-adds columns that already exist.
|
||||
cols = {row["name"] for row in conn.execute("PRAGMA table_info(tasks)")}
|
||||
|
||||
# Legacy column migration: ``spawn_failures`` → ``consecutive_failures``
|
||||
# and ``last_spawn_error`` → ``last_failure_error``.
|
||||
#
|
||||
|
|
@ -1069,11 +1077,6 @@ def _migrate_add_optional_columns(conn: sqlite3.Connection) -> None:
|
|||
#
|
||||
# ADD-first-then-copy is tolerant of both shapes and preserves
|
||||
# historical counter values when the legacy columns do exist.
|
||||
#
|
||||
# NOTE: ``cols`` reflects the schema at entry to this function and is
|
||||
# not refreshed between ALTER TABLE calls. Every guard below checks
|
||||
# the *original* snapshot; this is intentional and safe as long as
|
||||
# no step depends on a column added by a previous step in the same call.
|
||||
if "consecutive_failures" not in cols:
|
||||
added = _add_column_if_missing(
|
||||
conn,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue