CREATE TABLE nvd_records (
    id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    vulnerability_id BIGINT NOT NULL REFERENCES vulnerabilities (id) ON DELETE CASCADE,
    cve_id TEXT NOT NULL UNIQUE,
    cpe_configurations JSONB NOT NULL DEFAULT '[]'::jsonb,
    raw_data JSONB NOT NULL DEFAULT '{}'::jsonb,
    synced_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE INDEX nvd_records_vulnerability_id_idx
    ON nvd_records (vulnerability_id);
