fix(db): in_reply_to_id FK ON DELETE SET NULL — deleting a thought no longer blocks if it has replies
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 9m40s
test / unit (pull_request) Successful in 16m10s
test / integration (pull_request) Failing after 17m4s
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 9m40s
test / unit (pull_request) Successful in 16m10s
test / integration (pull_request) Failing after 17m4s
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
-- Change in_reply_to_id FK from RESTRICT (default) to SET NULL.
|
||||||
|
-- Previously, deleting a thought that had replies raised a FK violation.
|
||||||
|
-- With SET NULL, deleting a thought orphans its replies (they survive but
|
||||||
|
-- lose their parent reference), which is the correct semantic for a
|
||||||
|
-- threaded social app.
|
||||||
|
ALTER TABLE thoughts
|
||||||
|
DROP CONSTRAINT IF EXISTS thoughts_in_reply_to_id_fkey;
|
||||||
|
|
||||||
|
ALTER TABLE thoughts
|
||||||
|
ADD CONSTRAINT thoughts_in_reply_to_id_fkey
|
||||||
|
FOREIGN KEY (in_reply_to_id) REFERENCES thoughts(id) ON DELETE SET NULL;
|
||||||
Reference in New Issue
Block a user