CREATE TABLE IF NOT EXISTS job_analysis_results (
    id BIGSERIAL PRIMARY KEY,
    job_id BIGINT NOT NULL,
    analysis_result TEXT NOT NULL,
    match_score INTEGER,
    key_skills TEXT[],
    missing_skills TEXT[],
    recommendations TEXT,
    analyzed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE CASCADE
);

CREATE INDEX idx_job_analysis_results_job_id ON job_analysis_results(job_id);
CREATE INDEX idx_job_analysis_results_match_score ON job_analysis_results(match_score);
