Skip to content

[Tech Debt] Add FK constraint on comments.plot_index #231

@realproject7

Description

@realproject7

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:

  1. Application-level check in POST /api/comments: query plots table to verify the (storyline_id, plot_index) pair exists before inserting
  2. DB trigger/function: validate on insert

Option 1 is simpler and sufficient.

Acceptance Criteria

  • POST /api/comments returns 400 if (storyline_id, plot_index) doesn't exist in plots

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