Skip to content

docs: document database schema with table descriptions and ER diagram #49

Description

@charannyk06

Priority: P3 — Low

Problem

The SQLite schema is defined inline in src/server/store.ts and the Supabase schema is split across multiple migration files. There is no unified reference document describing:

  • What tables exist
  • What each column stores
  • How tables relate to each other
  • Why specific design decisions were made

Solution

Create docs/database-schema.md:

SQLite (Local — ~/.chainreview/chainreview.db)

Document each table:

### `runs`
Stores each review run.

| Column | Type | Description |
|--------|------|-------------|
| id | TEXT | UUID, primary key |
| repo_root | TEXT | Absolute path to repository root |
| status | TEXT | queued \| running \| complete \| failed |
| started_at | INTEGER | Unix timestamp |
| completed_at | INTEGER | Unix timestamp, null if not done |
| ...

### `findings`
Individual findings from agent analysis.

### `chat_messages`
Chat Q&A messages per run.

### `patch_applications`
Record of applied patches.

Supabase (Cloud — PostgreSQL)

Document tables from supabase/migrations/:

  • profiles — user accounts
  • api_keys — per-user API keys
  • usage — request/token tracking
  • subscriptions — Stripe subscription records

Mermaid ER Diagram

erDiagram
    runs ||--o{ findings : "has"
    runs ||--o{ chat_messages : "has"
    findings ||--o{ patch_applications : "has"
Loading

Acceptance Criteria

  • docs/database-schema.md documents all SQLite tables
  • Supabase tables documented
  • ER diagram (Mermaid)
  • Linked from DEVELOPMENT.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions