[#78] Ratings schema + RLS policy#83
Conversation
- Migration 00005_ratings.sql: creates ratings table with score 1-5, unique constraint on (storyline_id, rater_address) for upsert pattern - RLS: public read (FOR SELECT USING (true)), no public write - Database type in lib/supabase.ts updated with ratings Row/Insert/Update - Added Rating convenience type alias Fixes #78 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Summary
The PR is close, but the new migration does not match the existing schema and will fail when applied. There is also a missing storyline index compared with the issue's requested schema.
Findings
- [high] The foreign key in
ratings.storyline_idpoints atstorylines(id), but the existing schema keys related tables off the on-chain identifierstorylines.storyline_id. In this repo,plotsanddonationsboth referencestorylines(storyline_id), and issue #78 specifies the same. As written, the migration does not match the intended join key and can fail becausestorylines.idis not declared unique beyond the PK while the rest of the app types and queries are built aroundstoryline_id.- File:
supabase/migrations/00005_ratings.sql:6 - Suggestion: change the foreign key to
references storylines (storyline_id)so the ratings table lines up with the existing schema and issue spec.
- File:
- [medium] The migration omits the
idx_ratings_storylineindex that is part of the issue's schema sketch. This table will be read by storyline, so skipping that index is unnecessary regression against the requested shape.- File:
supabase/migrations/00005_ratings.sql - Suggestion: add
create index idx_ratings_storyline on ratings (storyline_id);.
- File:
Decision
Requesting changes because the foreign key target is incorrect and blocks the migration from matching the existing database model.
- FK now references storylines(storyline_id) matching existing pattern - Added idx_ratings_storyline index Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Summary
The foreign key and index fixes are correct, but the PR still diverges from issue #78 on the ratings column name. The issue schema specifies rating, while this PR creates and types a score column instead.
Findings
- [medium] The migration and Supabase types use
score, but issue #78 explicitly defines the schema asrating smallint not null check (rating between 1 and 5). This is not just naming style: the issue is asking for a concrete table shape, and introducing a different column name creates avoidable mismatch for follow-on work and any code written against the documented schema.- File:
supabase/migrations/00005_ratings.sql:8 - Suggestion: rename the column to
ratingin the migration and updatelib/supabase.tsaccordingly.
- File:
- [medium] The generated database types mirror the same schema drift by exposing
scoreinstead ofrating.- File:
lib/supabase.ts:174 - Suggestion: keep the TS types aligned with the final SQL column name from the issue spec.
- File:
Decision
Requesting one more change so the migration matches the issue's defined schema exactly.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Summary
The SQL migration now matches issue #78, but the Supabase types still contain one stale field name in the ratings.Update shape.
Findings
- [medium]
ratings.Updatestill usesscore?: numbereven though the table column is nowrating. That leaves the generated types inconsistent with the migration and will mislead any update code written against this interface.- File:
lib/supabase.ts:192 - Suggestion: rename
score?: numbertorating?: numberin theUpdatetype so all three shapes (Row/Insert/Update) align with the SQL schema.
- File:
Decision
Requesting one final type fix so the database types are fully consistent with the migration.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Summary
The migration and Supabase types now align with issue #78 and the existing schema conventions. The ratings table, RLS policy, index, and generated types are all consistent.
Findings
- No blocking findings.
Decision
Approving because the PR now matches the requested ratings schema and public-read/no-public-write policy.
Summary
00005_ratings.sql: createsratingstable with score (1-5), comment, unique constraint on(storyline_id, rater_address)for upsertFOR SELECT USING (true)), no public write (writes via service role only)Databasetype inlib/supabase.tswithratingsRow/Insert/Update typesRatingconvenience type aliasTest plan
npm run lintpassesnpm run typecheckpassesFixes #78
🤖 Generated with Claude Code