fix(comments): cascade delete replies in DB when parent comment is deleted
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>
This commit is contained in:
parent
8a9ae0102d
commit
6cc8f7586a
2 changed files with 6 additions and 0 deletions
3
server/migrations/018_comment_parent_cascade.down.sql
Normal file
3
server/migrations/018_comment_parent_cascade.down.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
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 SET NULL;
|
||||
3
server/migrations/018_comment_parent_cascade.up.sql
Normal file
3
server/migrations/018_comment_parent_cascade.up.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue