diff --git a/scripts/migrate-worker-heartbeat-db.sh b/scripts/migrate-worker-heartbeat-db.sh new file mode 100755 index 0000000..8466720 --- /dev/null +++ b/scripts/migrate-worker-heartbeat-db.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -euo pipefail + +DB_FILE="/opt/appfactory/data/appfactory/appfactory.db" + +python3 - "$DB_FILE" <<'PY' +import sqlite3 +import sys + +db_file = sys.argv[1] +con = sqlite3.connect(db_file) + +con.execute(""" +CREATE TABLE IF NOT EXISTS workers ( + id TEXT PRIMARY KEY, + status TEXT NOT NULL DEFAULT 'online', + started_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, + last_seen_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, + current_job_id INTEGER, + metadata_json TEXT +) +""") + +con.execute(""" +CREATE INDEX IF NOT EXISTS idx_workers_last_seen +ON workers(last_seen_at) +""") + +con.commit() +con.close() + +print("Worker heartbeat migration completed.") +PY