From 453cf12fc75fb5e1267dd87597cd1107d0ab98e1 Mon Sep 17 00:00:00 2001 From: Jiri Uhlir Date: Mon, 1 Jun 2026 13:15:56 +0200 Subject: [PATCH] Add service incidents database migration --- scripts/migrate-incidents-db.sh | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 scripts/migrate-incidents-db.sh diff --git a/scripts/migrate-incidents-db.sh b/scripts/migrate-incidents-db.sh new file mode 100755 index 0000000..d902c77 --- /dev/null +++ b/scripts/migrate-incidents-db.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +set -euo pipefail + +DB_FILE="/opt/appfactory/data/appfactory/appfactory.db" + +python3 - "$DB_FILE" <<'PY' +import sqlite3 +import sys + +con = sqlite3.connect(sys.argv[1]) + +con.execute(""" +CREATE TABLE IF NOT EXISTS service_incidents ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + + service_id TEXT NOT NULL, + + status TEXT NOT NULL, + + started_at TEXT NOT NULL, + ended_at TEXT, + + duration_seconds INTEGER, + + start_health_id INTEGER, + end_health_id INTEGER, + + title TEXT, + description TEXT +) +""") + +con.execute(""" +CREATE INDEX IF NOT EXISTS idx_service_incidents_service +ON service_incidents(service_id) +""") + +con.execute(""" +CREATE INDEX IF NOT EXISTS idx_service_incidents_status +ON service_incidents(status) +""") + +con.commit() +con.close() + +print("Incident migration completed") +PY