Files
appfactory-tools/scripts/migrate-incidents-db.sh

48 lines
820 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
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