diff --git a/core/db.py b/core/db.py index 74d01df..a54790d 100644 --- a/core/db.py +++ b/core/db.py @@ -663,10 +663,11 @@ def _migrate(conn: sqlite3.Connection): # Fix orphaned dept_sub pipelines left in 'running' state due to double-create bug # (KIN-ARCH-012): before the fix, _execute_department_head_step created a pipeline # that was never updated, leaving ghost 'running' records in prod DB. - conn.execute( - "UPDATE pipelines SET status = 'failed' WHERE route_type = 'dept_sub' AND status = 'running'" - ) - conn.commit() + if "pipelines" in existing_tables: + conn.execute( + "UPDATE pipelines SET status = 'failed' WHERE route_type = 'dept_sub' AND status = 'running'" + ) + conn.commit() def _seed_default_hooks(conn: sqlite3.Connection): diff --git a/tests/test_watchdog.py b/tests/test_watchdog.py index da5b2b9..cc7ec44 100644 --- a/tests/test_watchdog.py +++ b/tests/test_watchdog.py @@ -1,6 +1,7 @@ -"""Tests for pipeline watchdog (KIN-099, KIN-OBS-015).""" +"""Tests for pipeline watchdog (KIN-099, KIN-OBS-015, KIN-OBS-019).""" import errno +import inspect import json import os import threading