diff --git a/lib/db/migrations/024_lan_devices.sql b/lib/db/migrations/024_lan_devices.sql new file mode 100644 index 0000000..fb199e7 --- /dev/null +++ b/lib/db/migrations/024_lan_devices.sql @@ -0,0 +1,40 @@ +-- 024_lan_devices.sql +-- LAN device inventory keyed by MAC, fed by the hourly arp-scan. Separate from +-- network_hosts (homelab guests). New MACs land status='new' for owner review. +CREATE TABLE IF NOT EXISTS lan_devices ( + mac text PRIMARY KEY, + ip text, + vendor text, + name text, + grp text, + note text, + status text NOT NULL DEFAULT 'new', -- new | known | ignored + randomized boolean NOT NULL DEFAULT false, + flagged boolean NOT NULL DEFAULT false, + first_seen timestamptz NOT NULL DEFAULT now(), + last_seen timestamptz NOT NULL DEFAULT now(), + present boolean NOT NULL DEFAULT true +); + +-- Seed from the curated devices.json (MACs lowercased). Named devices -> 'known'; +-- the unidentified ASUS box -> 'new'. present=false until the first live scan. +INSERT INTO lan_devices (mac, ip, vendor, name, grp, status, flagged, randomized, present) VALUES + ('48:43:dd:fc:2f:84','192.168.1.3','Amazon','Amazon Echo','Smart Home','known',false,false,false), + ('14:0a:c5:6d:15:6e','192.168.1.4','Amazon','Amazon Echo','Smart Home','known',false,false,false), + ('c8:47:8c:01:17:70','192.168.1.6','Beken','Smart device','Smart Home','known',false,false,false), + ('d4:a6:51:12:36:92','192.168.1.23','Tuya','Smart device','Smart Home','known',false,false,false), + ('ec:4d:3e:36:ef:e1','192.168.1.20','Xiaomi','Xiaomi device','Smart Home','known',false,false,false), + ('1c:53:f9:bb:32:24','192.168.1.12','Google','Google / Nest','Entertainment','known',false,false,false), + ('d4:f5:47:95:33:93','192.168.1.14','Google','Google Nest Mini','Entertainment','known',false,false,false), + ('ec:4d:3e:37:38:8f','192.168.1.18','Google','Google / Nest','Entertainment','known',false,false,false), + ('48:70:1e:01:4f:7b','192.168.1.29','StreamMagic','Cambridge Audio','Entertainment','known',false,false,false), + ('08:66:98:b9:cf:f2','192.168.1.43','Apple','Apple TV / HomePod','Entertainment','known',false,false,false), + ('1c:86:9a:4c:f0:ec','192.168.1.24','Samsung','Samsung TV','Entertainment','known',false,false,false), + ('5a:da:61:7a:0f:12','192.168.1.171','Samsung','Galaxy Tab S4','Personal','known',false,true,false), + ('1c:57:dc:70:e8:2d','192.168.1.133','Apple','Apple device','Personal','known',false,false,false), + ('a0:d0:5b:04:70:96','192.168.1.61','Samsung','Samsung device','Personal','known',false,false,false), + ('14:eb:b6:40:7e:93','192.168.1.10','TP-Link','TP-Link device','Personal','known',false,false,false), + ('44:a5:6e:68:d0:e9','192.168.1.1','Netgear','Gateway / Router','Network','known',false,false,false), + ('bc:a5:11:3e:06:88','192.168.1.13','Netgear (Orbi mesh)','Orbi Satellite','Network','known',false,false,false), + ('24:4b:fe:8e:09:a4','192.168.1.15','ASUSTek','ASUS device','Flagged','new',true,false,false) +ON CONFLICT (mac) DO NOTHING;