Skip to content

[#185] DB schema: title column on plots + comments table + API#225

Merged
realproject7 merged 2 commits intomainfrom
task/185-p9-schema
Mar 16, 2026
Merged

[#185] DB schema: title column on plots + comments table + API#225
realproject7 merged 2 commits intomainfrom
task/185-p9-schema

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Migration: title TEXT DEFAULT '' on plots table; comments table with indexes on (storyline_id, plot_index) and (commenter_address), RLS for public read
  • Types: Added title to Plot type, added Comment type alias
  • Plot indexer: Extracts title from updated PlotChained event and stores it
  • Comments API: GET /api/comments?storylineId=N&plotIndex=M (paginated, 20/page) + POST /api/comments (wallet signature auth, 1 comment per address per plot per minute, max 1000 chars)

Test plan

  • Run migration on Supabase
  • Chain a plot with title → verify title stored in plots table
  • Chain a plot without title → verify empty string stored
  • POST /api/comments with valid signature → success
  • POST /api/comments twice within 1 min → 429
  • GET /api/comments returns paginated results
  • Hidden comments not returned by GET

Fixes #185

🤖 Generated with Claude Code

Migration:
- ALTER TABLE plots ADD COLUMN title TEXT DEFAULT ''
- CREATE TABLE comments (storyline_id, plot_index, commenter_address,
  content, created_at, hidden) with indexes and RLS

Types:
- Added title field to Plot type (Row/Insert/Update)
- Added Comment type with full Row/Insert/Update definitions

Plot indexer:
- Extracts title from PlotChained event args and stores it

Comments API:
- GET /api/comments?storylineId=N&plotIndex=M — paginated, 20 per page
- POST /api/comments — wallet signature auth, 1 comment per address
  per plot per minute rate limit, max 1000 chars

Fixes #185

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The schema and indexer pieces look aligned with #185, but the new comments read API does not match the API contract defined in the issue. That makes the foundation inconsistent for the blocked Phase 9 comment UI work.

Findings

  • [high] GET /api/comments implements the wrong pagination contract
    • File: src/app/api/comments/route.ts:14
    • File: src/app/api/comments/route.ts:30
    • Suggestion: implement the issue-specified page and limit query params, or at minimum accept them compatibly and derive the Supabase range from those values. Right now the route only accepts offset and hardcodes PAGE_SIZE = 20, but issue #185 explicitly defines GET /api/comments?storylineId=X&plotIndex=Y&page=1&limit=20.

Decision

Requesting changes because #185 is the schema/API foundation for later comment UI work, and the shipped API contract should match the issue rather than introducing a different pagination shape.

Accept page (default 1) and limit (default 20, max 100) instead of
raw offset. Matches the API shape specified in #185 for Phase 9 UI.
Addresses T2a review feedback on PR #225.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The follow-up change fixes the API contract mismatch by implementing page and limit query params on GET /api/comments, which aligns the route with issue #185. The schema, types, plot-title indexing, and comments API foundation now look consistent for the blocked Phase 9 frontend work.

Findings

  • None.

Decision

Approving because the previously blocking pagination contract gap is resolved, and GitHub lint-and-typecheck passes on the updated head.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b: APPROVE

Well-structured schema + API foundation for Phase 9:

  • Migration: title on plots, comments table with proper indexes, RLS filtering hidden rows
  • Plot indexer: Correctly extracts title from updated PlotChained event
  • Comments GET: page/limit pagination with total count — matches issue #185 spec
  • Comments POST: Strong auth — wallet signature binds to specific comment content (prevents replay), 1/min rate limit per address per plot, 1000 char max
  • Types: Supabase types and Comment export updated consistently

Minor nit: GET route code comment (line 16) still references offset=0 but code uses page/limit. Cosmetic only.

@realproject7 realproject7 merged commit 15822e1 into main Mar 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P9-2] DB schema: add title to plots + create comments table

2 participants