From fa31fc37d0fb93157d6976f0b5d6e4ed9b8b0769 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 8 Dec 2024 08:44:37 -0500 Subject: [PATCH] Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas --- migrations/2024-12-02-181601_add_report_combined_table/up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/2024-12-02-181601_add_report_combined_table/up.sql b/migrations/2024-12-02-181601_add_report_combined_table/up.sql index 40dd9b277..4d450269c 100644 --- a/migrations/2024-12-02-181601_add_report_combined_table/up.sql +++ b/migrations/2024-12-02-181601_add_report_combined_table/up.sql @@ -7,7 +7,7 @@ CREATE TABLE report_combined ( comment_report_id int UNIQUE REFERENCES comment_report ON UPDATE CASCADE ON DELETE CASCADE, private_message_report_id int UNIQUE REFERENCES private_message_report ON UPDATE CASCADE ON DELETE CASCADE, -- Make sure only one of the columns is not null - CHECK ((post_report_id IS NOT NULL)::integer + (comment_report_id IS NOT NULL)::integer + (private_message_report_id IS NOT NULL)::integer = 1) + CHECK (num_nonnulls (post_report_id, comment_report_id, private_message_report_id) = 1) ); CREATE INDEX idx_report_combined_published ON report_combined (published DESC, id DESC);