Problem
The comments table has storyline_id referencing storylines(storyline_id), but no compound constraint ensuring the plot_index actually exists in the plots table. Users could post comments on non-existent plot indexes.
Fix
Add a check or FK to validate plot existence. Options:
- Application-level check in POST /api/comments: query
plots table to verify the (storyline_id, plot_index) pair exists before inserting
- DB trigger/function: validate on insert
Option 1 is simpler and sufficient.
Acceptance Criteria
Problem
The
commentstable hasstoryline_idreferencingstorylines(storyline_id), but no compound constraint ensuring theplot_indexactually exists in theplotstable. Users could post comments on non-existent plot indexes.Fix
Add a check or FK to validate plot existence. Options:
plotstable to verify the (storyline_id, plot_index) pair exists before insertingOption 1 is simpler and sufficient.
Acceptance Criteria