From 10f5e373cf0e282c113a86f41bc0753fa3db7ca2 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 8 Dec 2024 08:45:49 -0500 Subject: [PATCH] Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas --- .../up.sql | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) 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 4d450269c..8425f5d0d 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 @@ -15,23 +15,27 @@ CREATE INDEX idx_report_combined_published ON report_combined (published DESC, i CREATE INDEX idx_report_combined_published_asc ON report_combined (reverse_timestamp_sort (published) DESC, id DESC); -- Updating the history -INSERT INTO report_combined (published, post_report_id) +INSERT INTO report_combined (published, post_report_id, comment_report_id, private_message_report_id) SELECT published, - id + id, + NULL, + NULL FROM - post_report; - -INSERT INTO report_combined (published, comment_report_id) + post_report +UNION ALL SELECT published, - id + NULL, + id, + NULL FROM - comment_report; - -INSERT INTO report_combined (published, private_message_report_id) + comment_report +UNION ALL SELECT published, + NULL, + NULL, id FROM private_message_report;