create table if not exists scan_interfaces ( id bigserial primary key, scan_id text not null references scan_jobs(id) on delete cascade, ip inet not null, if_index int not null, if_descr text null, if_name text null, if_oper_status text null, checked_at timestamptz not null ); create index if not exists idx_scan_interfaces_scan_ip_idx on scan_interfaces (scan_id, ip, if_index);