Change parent_id FK from ON DELETE SET NULL to ON DELETE CASCADE. Deleting a parent comment now deletes all its replies at the DB level. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 lines
198 B
SQL
3 lines
198 B
SQL
ALTER TABLE comment DROP CONSTRAINT IF EXISTS comment_parent_id_fkey;
|
|
ALTER TABLE comment ADD CONSTRAINT comment_parent_id_fkey
|
|
FOREIGN KEY (parent_id) REFERENCES comment(id) ON DELETE CASCADE;
|