schema.sql 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. PRAGMA foreign_keys = ON;
  2. CREATE TABLE system_prompts (
  3. hash TEXT PRIMARY KEY,
  4. name TEXT NOT NULL,
  5. content TEXT NOT NULL,
  6. created_at DATETIME DEFAULT CURRENT_TIMESTAMP
  7. );
  8. CREATE TABLE processing_functions (
  9. hash TEXT PRIMARY KEY,
  10. name TEXT NOT NULL,
  11. parsing_function TEXT NOT NULL,
  12. diff_edit_function TEXT NOT NULL,
  13. created_at DATETIME DEFAULT CURRENT_TIMESTAMP
  14. );
  15. CREATE TABLE files (
  16. hash TEXT PRIMARY KEY,
  17. filepath TEXT NOT NULL,
  18. content TEXT NOT NULL,
  19. tokens INTEGER,
  20. created_at DATETIME DEFAULT CURRENT_TIMESTAMP
  21. );
  22. CREATE TABLE runs (
  23. run_id TEXT PRIMARY KEY,
  24. created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  25. description TEXT,
  26. system_prompt_hash TEXT NOT NULL,
  27. FOREIGN KEY (system_prompt_hash) REFERENCES system_prompts(hash)
  28. );
  29. CREATE TABLE cases (
  30. case_id TEXT PRIMARY KEY,
  31. run_id TEXT NOT NULL,
  32. created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  33. description TEXT NOT NULL,
  34. system_prompt_hash TEXT NOT NULL,
  35. task_id TEXT NOT NULL,
  36. tokens_in_context INTEGER,
  37. file_hash TEXT,
  38. FOREIGN KEY (run_id) REFERENCES runs(run_id),
  39. FOREIGN KEY (system_prompt_hash) REFERENCES system_prompts(hash),
  40. FOREIGN KEY (file_hash) REFERENCES files(hash)
  41. );
  42. CREATE TABLE results (
  43. result_id TEXT PRIMARY KEY,
  44. run_id TEXT NOT NULL,
  45. case_id TEXT NOT NULL,
  46. model_id TEXT NOT NULL,
  47. processing_functions_hash TEXT NOT NULL,
  48. succeeded BOOLEAN NOT NULL,
  49. error_enum INTEGER,
  50. num_edits INTEGER,
  51. num_lines_deleted INTEGER,
  52. num_lines_added INTEGER,
  53. time_to_first_token_ms INTEGER,
  54. time_to_first_edit_ms INTEGER,
  55. time_round_trip_ms INTEGER,
  56. cost_usd REAL,
  57. completion_tokens INTEGER,
  58. raw_model_output TEXT,
  59. file_edited_hash TEXT,
  60. parsed_tool_call_json TEXT,
  61. created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  62. FOREIGN KEY (run_id) REFERENCES runs(run_id),
  63. FOREIGN KEY (case_id) REFERENCES cases(case_id),
  64. FOREIGN KEY (processing_functions_hash) REFERENCES processing_functions(hash)
  65. );
  66. CREATE INDEX idx_results_run_model ON results(run_id, model_id);
  67. CREATE INDEX idx_results_case_model ON results(case_id, model_id);
  68. CREATE INDEX idx_results_success ON results(succeeded);
  69. CREATE INDEX idx_cases_run ON cases(run_id);
  70. CREATE INDEX idx_results_created_at ON results(created_at);
  71. CREATE INDEX idx_runs_created_at ON runs(created_at);