Spaces:
Running
Running
fix: wrap kanban table migration in try/except to prevent startup crashes on existing databases
Browse files- Dockerfile +39 -0
Dockerfile
CHANGED
|
@@ -25,6 +25,45 @@ RUN chmod +x \
|
|
| 25 |
/opt/huggingmes/cloudflare-proxy-setup.py \
|
| 26 |
/opt/huggingmes/cloudflare-keepalive-setup.py
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
ENV HERMES_HOME=/opt/data \
|
| 29 |
HUGGINGMES_APP_DIR=/opt/huggingmes \
|
| 30 |
HERMES_AGENT_VERSION=${HERMES_AGENT_VERSION} \
|
|
|
|
| 25 |
/opt/huggingmes/cloudflare-proxy-setup.py \
|
| 26 |
/opt/huggingmes/cloudflare-keepalive-setup.py
|
| 27 |
|
| 28 |
+
# Patch kanban migration: wrap ALTER TABLE ADD COLUMN in try/except so a
|
| 29 |
+
# persisted DB with the column already present doesn't crash the gateway.
|
| 30 |
+
RUN python3 - <<'PY'
|
| 31 |
+
from pathlib import Path
|
| 32 |
+
import sys
|
| 33 |
+
|
| 34 |
+
p = Path("/opt/hermes/hermes_cli/kanban_db.py")
|
| 35 |
+
if not p.exists():
|
| 36 |
+
sys.exit(0)
|
| 37 |
+
|
| 38 |
+
src = p.read_text(encoding="utf-8")
|
| 39 |
+
sentinel = "# huggingmes: idempotent-alter"
|
| 40 |
+
if sentinel in src:
|
| 41 |
+
sys.exit(0)
|
| 42 |
+
|
| 43 |
+
old = (
|
| 44 |
+
' conn.execute(\n'
|
| 45 |
+
' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
|
| 46 |
+
' "INTEGER NOT NULL DEFAULT 0"\n'
|
| 47 |
+
' )'
|
| 48 |
+
)
|
| 49 |
+
new = (
|
| 50 |
+
f' try: {sentinel}\n'
|
| 51 |
+
' conn.execute(\n'
|
| 52 |
+
' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
|
| 53 |
+
' "INTEGER NOT NULL DEFAULT 0"\n'
|
| 54 |
+
' )\n'
|
| 55 |
+
' except Exception:\n'
|
| 56 |
+
' pass'
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
if old not in src:
|
| 60 |
+
print("kanban patch: pattern not found — may be fixed upstream, skipping")
|
| 61 |
+
sys.exit(0)
|
| 62 |
+
|
| 63 |
+
p.write_text(src.replace(old, new), encoding="utf-8")
|
| 64 |
+
print("kanban patch: applied")
|
| 65 |
+
PY
|
| 66 |
+
|
| 67 |
ENV HERMES_HOME=/opt/data \
|
| 68 |
HUGGINGMES_APP_DIR=/opt/huggingmes \
|
| 69 |
HERMES_AGENT_VERSION=${HERMES_AGENT_VERSION} \
|