create table `gateway_heartbeats` (
  `id` int auto_increment primary key not null,
  `gateway_id` int not null,
  `hostname` varchar(160),
  `lan_ip` varchar(64),
  `ssid` varchar(160),
  `ui_port` int,
  `app_version` varchar(64),
  `health_summary_json` longtext,
  `last_heartbeat_at` datetime not null,
  `updated_at` datetime not null default CURRENT_TIMESTAMP
);

create unique index `gateway_heartbeats_gateway_id_uq` on `gateway_heartbeats` (`gateway_id`);
create index `gateway_heartbeats_last_heartbeat_at_idx` on `gateway_heartbeats` (`last_heartbeat_at`);
