From b901714d7138397c3504dd76e164ecf52165b95c Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 14 Jan 2025 10:48:56 -0500 Subject: [PATCH] Fixing person_content_combined migration uniques. (#5324) --- .../up.sql | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/migrations/2024-12-05-233704_add_person_content_combined_table/up.sql b/migrations/2024-12-05-233704_add_person_content_combined_table/up.sql index 805d2ca94..63a4d1f39 100644 --- a/migrations/2024-12-05-233704_add_person_content_combined_table/up.sql +++ b/migrations/2024-12-05-233704_add_person_content_combined_table/up.sql @@ -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) );