Fixing person_content_combined migration uniques. (#5324)

This commit is contained in:
Dessalines 2025-01-14 10:48:56 -05:00 committed by GitHub
parent 9c1347c7a0
commit b901714d71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,8 +33,12 @@ CREATE TABLE person_saved_combined (
id serial PRIMARY KEY,
saved timestamptz NOT NULL,
person_id int NOT NULL REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE,
post_id int UNIQUE REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE,
comment_id int UNIQUE REFERENCES COMMENT ON UPDATE CASCADE ON DELETE CASCADE,
post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE,
comment_id int REFERENCES COMMENT ON UPDATE CASCADE ON DELETE CASCADE,
-- Unique constraints are different here, check for person AND item.
-- Otherwise you won't be able to add multiple posts
UNIQUE (person_id, post_id),
UNIQUE (person_id, comment_id),
-- Make sure only one of the columns is not null
CHECK (num_nonnulls (post_id, comment_id) = 1)
);