Skip to content

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

@realproject7

Description

@realproject7

Changes

1. Add title column to plots table

ALTER TABLE plots ADD COLUMN title TEXT DEFAULT '';
  • Default empty string for backward compatibility with existing plots
  • Update Supabase TypeScript types in lib/supabase.ts
  • Update plot indexer (/api/index/plot/route.ts) to extract title from PlotChained event

2. Create comments table

CREATE TABLE comments (
  id SERIAL PRIMARY KEY,
  storyline_id INTEGER NOT NULL REFERENCES storylines(storyline_id),
  plot_index INTEGER NOT NULL,  -- 0 = genesis, 1+ = chapter
  commenter_address TEXT NOT NULL,
  content TEXT NOT NULL,
  created_at TIMESTAMPTZ DEFAULT NOW(),
  hidden BOOLEAN DEFAULT FALSE
);

CREATE INDEX idx_comments_storyline_plot ON comments(storyline_id, plot_index);
CREATE INDEX idx_comments_commenter ON comments(commenter_address);
  • plot_index = 0 for comments on genesis
  • plot_index = N for comments on chapter N
  • hidden for moderation support
  • Update Supabase TypeScript types

3. Create comments API routes

  • GET /api/comments?storylineId=X&plotIndex=Y&page=1&limit=20 — paginated fetch
  • POST /api/comments — create comment (requires wallet signature)

Blocked by

#184 (contract must be deployed first for title in events)

Part of

Phase 9 Epic (#183)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions