-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
32 lines (29 loc) · 1.07 KB
/
init.sql
File metadata and controls
32 lines (29 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
CREATE TABLE IF NOT EXISTS services (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
url TEXT NOT NULL,
method TEXT NOT NULL DEFAULT 'GET',
timeout INTEGER NOT NULL DEFAULT 10000,
expected_status INTEGER NOT NULL DEFAULT 200,
created_at INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS health_checks (
id TEXT PRIMARY KEY,
service_id TEXT NOT NULL,
status TEXT NOT NULL CHECK(status IN ('healthy', 'unhealthy')),
response_time INTEGER NOT NULL,
status_code INTEGER,
error TEXT,
timestamp INTEGER NOT NULL,
FOREIGN KEY (service_id) REFERENCES services(id) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS notifications (
id TEXT PRIMARY KEY,
type TEXT NOT NULL CHECK(type IN ('telegram', 'slack')),
enabled INTEGER NOT NULL DEFAULT 1 CHECK(enabled IN (0, 1)),
config TEXT NOT NULL,
created_at INTEGER NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_health_checks_service_id ON health_checks(service_id);
CREATE INDEX IF NOT EXISTS idx_health_checks_timestamp ON health_checks(timestamp DESC);
CREATE INDEX IF NOT EXISTS idx_health_checks_status ON health_checks(status);