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`);