- Alerts can be acknowledged (note, assignee, duration); acknowledged alerts are left out of what needs attention (sidebar, dashboard strip, cards) but stay raised and counted by /metrics - Incidents: each time an alert is raised and goes away is recorded (alert_acks, alert_incidents, incident_notes, migration 0032), with a timeline of acks, maintenance, changes, update runs, related alerts and notes; Incidents page and a digest section - Backups of Homelab Manager's own database: daily checked VACUUM INTO copies, retention, download, check, upload, delete, and restore staged and applied at start-up before the database opens (pre-restore copy kept); alerts and /metrics for stale or failing backups - Docs: README, BACKUP, DATABASE, NOTIFICATIONS, ROLES, API; tests Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
46 lines
1.7 KiB
SQL
46 lines
1.7 KiB
SQL
CREATE TABLE `alert_acks` (
|
|
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
`alert_key` text NOT NULL,
|
|
`note` text DEFAULT '' NOT NULL,
|
|
`assignee_user_id` integer,
|
|
`assignee_name` text,
|
|
`acked_by` text NOT NULL,
|
|
`acked_at` text NOT NULL,
|
|
`until` text,
|
|
`last_seen_at` text NOT NULL,
|
|
FOREIGN KEY (`assignee_user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `alert_acks_key_idx` ON `alert_acks` (`alert_key`);--> statement-breakpoint
|
|
CREATE TABLE `alert_incidents` (
|
|
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
`alert_key` text NOT NULL,
|
|
`severity` text NOT NULL,
|
|
`peak_severity` text NOT NULL,
|
|
`category` text NOT NULL,
|
|
`source` text NOT NULL,
|
|
`message` text NOT NULL,
|
|
`link` text,
|
|
`target_type` text,
|
|
`target_id` integer,
|
|
`target_name` text,
|
|
`caused_by` text,
|
|
`opened_at` text NOT NULL,
|
|
`resolved_at` text,
|
|
`last_seen_at` text NOT NULL,
|
|
`missing_since` text
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `alert_incidents_key_idx` ON `alert_incidents` (`alert_key`);--> statement-breakpoint
|
|
CREATE INDEX `alert_incidents_opened_idx` ON `alert_incidents` (`opened_at`);--> statement-breakpoint
|
|
CREATE INDEX `alert_incidents_target_idx` ON `alert_incidents` (`target_type`,`target_id`);--> statement-breakpoint
|
|
CREATE TABLE `incident_notes` (
|
|
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
`incident_id` integer NOT NULL,
|
|
`author` text NOT NULL,
|
|
`body` text NOT NULL,
|
|
`created_at` text NOT NULL,
|
|
FOREIGN KEY (`incident_id`) REFERENCES `alert_incidents`(`id`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `incident_notes_incident_idx` ON `incident_notes` (`incident_id`); |