feat: add comment threading backend (depth, indexing, API) (#125)
* feat(api): add depth column to replies table
Add integer depth column (NOT NULL, default 1) for thread nesting.
Add composite index on (root_uri, depth) for depth-filtered queries.
Direct replies to topic = depth 1, nested = parent_depth + 1.
* feat(api): add maxReplyDepth to community settings
Add integer max_reply_depth column (NOT NULL, default 9999) for
admin-configurable threading depth. 9999 means effectively unlimited.
* feat(api): add threading constants
* chore(api): generate migration for threading schema
Adds depth column to replies, max_reply_depth to community_settings,
and composite index on (root_uri, depth).
* feat(api): add backfill script for reply depth
Recursive CTE computes correct depth for all existing replies.
Direct replies to topic = 1, nested = parent_depth + 1. Idempotent.
* feat(api): compute reply depth on firehose indexing and optimistic insert
Direct replies to topic get depth 1. Nested replies look up parent
depth and add 1. Falls back to depth 1 if parent not found.
* feat(api): add depth query param, childCount, and maxReplyDepth admin setting
- serializeReply now uses stored depth column instead of naive computation
- GET replies accepts ?depth= param (default 10, max 100)
- Response includes childCount for depth-limited branches
- maxReplyDepth added to admin settings GET/PUT and public settings
- Updated mock DB to support groupBy as terminal chain method
- Updated test fixtures with depth field and new convention (1-indexed)
* chore(api): regenerate migration after merge with main
Removes old 0001_modern_master_mold migration (conflicted with main's
0001_add_favicon_url). Regenerated as 0004_threading-schema with same
content: depth column on replies, max_reply_depth on community_settings,
composite index.
* fix(api): add threading columns to tenant-isolation test schema
The integration test creates its own DB schema via raw SQL rather than
using Drizzle migrations. Add the missing depth and max_reply_depth
columns so Drizzle ORM inserts don't fail.
* chore(api): trigger CI re-run
* docs(api): add JSDoc comments to threading constants
* chore(api): renumber threading migration to 0005 after merge
Main added 0004_add_pages_table, so our threading migration becomes
0005_threading-schema.
authored by