Files
nuzlocke-tracker/.beans/archive/nuzlocke-tracker-vmto--backend-journal-entries-model-api-and-migration.md
Julian Tabel a6cb309b8b
All checks were successful
CI / backend-tests (push) Successful in 28s
CI / frontend-tests (push) Successful in 28s
chore: archive 42 completed/scrapped beans
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 21:31:23 +01:00

2.5 KiB

title, status, type, priority, tags, created_at, updated_at, parent
title status type priority tags created_at updated_at parent
Backend: Journal entries model, API, and migration completed task normal
failed
2026-03-20T15:15:48Z 2026-03-20T15:30:47Z nuzlocke-tracker-mz16

Create the backend infrastructure for session journal entries.

Data Model

journal_entries table:

  • id (UUID, PK)
  • run_id (FK to runs)
  • boss_result_id (FK to boss_results, nullable) — optional link to a boss battle
  • title (str, required)
  • body (text, required) — raw markdown content
  • created_at, updated_at (timestamps)

Checklist

  • Create Alembic migration for journal_entries table
  • Create JournalEntry SQLAlchemy model with relationships to Run and BossResult
  • Create Pydantic schemas (JournalEntryCreate, JournalEntryUpdate, JournalEntryResponse)
  • Create CRUD operations for journal entries
  • Create API endpoints under /runs/{run_id}/journal:
    • GET / — list entries for a run (ordered by created_at desc)
    • POST / — create entry
    • GET /{entry_id} — get single entry
    • PUT /{entry_id} — update entry
    • DELETE /{entry_id} — delete entry
  • Add optional boss_result_id query filter to GET list endpoint

Summary of Changes

Implemented backend infrastructure for session journal entries:

Files created:

  • backend/src/app/alembic/versions/k2f3a4b5c6d7_add_journal_entries_table.py - Migration creating journal_entries table with UUID PK, foreign keys to nuzlocke_runs and boss_results, and timestamp columns
  • backend/src/app/models/journal_entry.py - SQLAlchemy model with relationships to NuzlockeRun and BossResult
  • backend/src/app/schemas/journal_entry.py - Pydantic schemas for create, update, and response
  • backend/src/app/api/journal_entries.py - API endpoints for CRUD operations

Files modified:

  • backend/src/app/models/nuzlocke_run.py - Added journal_entries relationship
  • backend/src/app/models/__init__.py - Exported JournalEntry
  • backend/src/app/schemas/__init__.py - Exported journal entry schemas
  • backend/src/app/api/routes.py - Registered journal entries router

API Endpoints:

  • GET /runs/{run_id}/journal - List entries (supports boss_result_id filter)
  • POST /runs/{run_id}/journal - Create entry
  • GET /runs/{run_id}/journal/{entry_id} - Get single entry
  • PUT /runs/{run_id}/journal/{entry_id} - Update entry
  • DELETE /runs/{run_id}/journal/{entry_id} - Delete entry