create table agent_inventory_report_packages
(
    id              bigint generated by default as identity primary key,
    report_asset_id bigint      not null references agent_inventory_report_assets (id) on update cascade on delete cascade,
    task_id         bigint      not null references task_reports (task_id) on update cascade on delete cascade,
    asset_id        bigint references hosts (id) on update cascade on delete set null,
    observed_ip     inet        not null,
    name            text        not null,
    version         text        not null default '',
    created_at      timestamptz not null default now()
);

create index agent_inventory_report_packages_report_asset_id_idx on agent_inventory_report_packages (report_asset_id);
create index agent_inventory_report_packages_task_id_idx on agent_inventory_report_packages (task_id);
create index agent_inventory_report_packages_asset_id_idx on agent_inventory_report_packages (asset_id);
create index agent_inventory_report_packages_observed_ip_idx on agent_inventory_report_packages (observed_ip);
create index agent_inventory_report_packages_name_idx on agent_inventory_report_packages (name);
