-- Store exercise research summaries and sources
CREATE TABLE IF NOT EXISTS research_results (
  id SERIAL PRIMARY KEY,
  exercise_id INTEGER NOT NULL REFERENCES exercises(id) ON DELETE CASCADE,
  query TEXT NOT NULL,
  summary TEXT,
  results JSONB NOT NULL DEFAULT '[]'::jsonb,
  provider VARCHAR(50) NOT NULL DEFAULT 'exa',
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX IF NOT EXISTS idx_research_results_exercise_id ON research_results(exercise_id);
CREATE INDEX IF NOT EXISTS idx_research_results_created_at ON research_results(created_at);
