34 lines
671 B
Bash
Executable File
34 lines
671 B
Bash
Executable File
#!/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
|