Files
Homelab-manager/server/drizzle/0044_sparkling_scourge.sql
T
bobbanandClaude Sonnet 5.5 396e074108 UniFi integration: network devices, Wi-Fi and networks, as part of the dependency map
A UniFi controller (API key on Network 9+, or a read-only local login on any
version) is read every five minutes. Its switches, access points and gateways
are kept with state, IP, uptime, firmware and uplink; its networks and Wi-Fi
names beside them (passphrases are never read). Nothing is written to the
controller.

Network > Network devices lists them. Devices are a new node type in the
dependency map: uplinks become dependencies by themselves, others can be
written by hand. A device offline past a limit is an offline alert, folds what
depends on it, can be silenced with maintenance and have runbooks.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 00:35:48 +02:00

41 lines
1.4 KiB
SQL

CREATE TABLE `network_devices` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`integration_id` integer NOT NULL,
`external_id` text NOT NULL,
`site_name` text,
`name` text NOT NULL,
`model` text,
`kind` text DEFAULT 'other' NOT NULL,
`ip` text,
`mac` text,
`state` text DEFAULT 'other' NOT NULL,
`uptime_seconds` integer,
`firmware` text,
`firmware_updatable` integer DEFAULT false NOT NULL,
`uplink_external_id` text,
`offline_since` text,
`last_online_at` text,
`first_seen_at` text NOT NULL,
`updated_at` text NOT NULL,
FOREIGN KEY (`integration_id`) REFERENCES `integrations`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `network_devices_unique` ON `network_devices` (`integration_id`,`external_id`);--> statement-breakpoint
CREATE TABLE `network_segments` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`integration_id` integer NOT NULL,
`kind` text NOT NULL,
`external_id` text NOT NULL,
`site_name` text,
`name` text NOT NULL,
`enabled` integer DEFAULT true NOT NULL,
`vlan_id` integer,
`subnet` text,
`purpose` text,
`security` text,
`network_name` text,
`updated_at` text NOT NULL,
FOREIGN KEY (`integration_id`) REFERENCES `integrations`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `network_segments_unique` ON `network_segments` (`integration_id`,`kind`,`external_id`);