Overview
Build API endpoints to list version history for a topic and restore a previous version. The versions table and snapshot creation already exist (from #9, #21, #24). This adds the read + restore endpoints.
User Story
User Story: /docs/user-stories/active/version-history.md
As a user, I want to see a history of changes and restore any previous version, so I can undo AI changes I don't like.
Suggested Priority: high 🟠
Requirements
List Versions
Get Version Snapshot
Restore Version
Technical Approach
- Versions table exists with
topic_id, snapshot (JSONB), action, created_at
- Restore flow: snapshot current → delete all nodes → insert from target snapshot → return
- Use the same FK-aware delete order as _cleanup_partial_insert
- The restored nodes need new UUIDs (can't reuse old IDs if they conflict)
Related
Overview
Build API endpoints to list version history for a topic and restore a previous version. The versions table and snapshot creation already exist (from #9, #21, #24). This adds the read + restore endpoints.
User Story
User Story:
/docs/user-stories/active/version-history.mdAs a user, I want to see a history of changes and restore any previous version, so I can undo AI changes I don't like.
Suggested Priority: high 🟠
Requirements
List Versions
GET /api/topics/{topic_id}/versionsreturns version historyGet Version Snapshot
GET /api/topics/{topic_id}/versions/{version_id}returns full snapshotRestore Version
POST /api/topics/{topic_id}/versions/{version_id}/restoreTechnical Approach
topic_id,snapshot(JSONB),action,created_atRelated
/docs/user-stories/active/version-history.mdsupabase/migrations/20260330120000_create_schema.sql