lemmy/migrations/2025-08-01-000026_add_inbox_combined_table/up.sql

72 lines
2.5 KiB
MySQL
Raw Permalink Normal View History

Adding combined inbox (#5257) * Renaming person_mention to person_comment_mention. * Finishing up post body mentions. * Combined tables try 2 * Finishing up combined report table. * Fix ts optionals. * Adding tests, triggers, and history updates for report_combined. * Adding profile. * Add cursor pagination to report_combined view (#5244) * add pagination cursor * store timestamp instead of id in cursor (partial) * Revert "store timestamp instead of id in cursor (partial)" This reverts commit 89359dde4bc5fee39fdd2840828330f398444a36. * use paginated query builder * Fixing migration and paged API. * Using dullbananas trigger procedure * Removing pointless list routes, reorganizing tests. * Fixing column XOR check. * Forgot to remove list report actions. * Cleanup. * Use internal tagging. * Fixing api tests. * Adding a few indexes. * Fixing migration name. * Fixing unique constraints. * Addressing PR comments. * Start working on profile combined * Adding views and replaceable schema. * A few changes to profile view. - Separating the profile fetch from its combined content fetch. - Starting to separate saved_only into its own combined view. * Finishing up combined person_saved and person_content. * Fixing api tests. * Moving to api-v4 routes. * Fixing imports. * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Fixing import and fmt. * Fixing null types in postgres. * Comment out err. * Fixing TS issues. * Adding types, fixing allow and blocklist crud. * Starting to work on combined views. * Using dullbananas trigger procedure * Adding the full combined view queries. * Adding tests. * taplo fmt. * Upgrading package.json deps. * Updating pnpm * Most of the bulk work done, need to add tests yet. * Finishing up inbox. * Using assert_length * Fixing sql_format. * Running fmt. * Fixing cargo shear. * Fixing clippy. * Addressing PR comments. * Removing serialization * Removing serialization * Fixing duped trigger. * Remove saved_only test. * Remove pointless post_tags types. * Remove pointless index. * Changing published to saved for person_saved_combined. * Removing comment. * Renaming modlog when_ columns to published. - Fixes #5312 * Adding strum and simplifying imports. * Avoiding clone in map_to_enum * Changing modded_person to other_person. * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Addressing PR comments. * Fixing split. * Revert "Adding strum and simplifying imports." This reverts commit 15f167110721429dd6e465f522250c8beb3d4dd7. * Running fmt. * Using assert + matches instead of filter_map. * Adding listPersonContent check. * Updating lemmy-js-client * Fixing mark all as read route, changing mark read to SuccessResponse. * Adding post body mention api test, fixing api tests. * Fixing route locations, and api tests. --------- Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-01-15 17:51:39 +00:00
-- Creates combined tables for
-- Inbox: (replies, comment mentions, post mentions, and private_messages)
-- Also add post mentions, since these didn't exist before.
-- Rename the person_mention table to person_comment_mention
ALTER TABLE person_mention RENAME TO person_comment_mention;
-- Create the new post_mention table
CREATE TABLE person_post_mention (
Fast history no background (#5873) * Finishing up post and comment actions * Adding community_actions. * instance and person actions * Fixing person_actions. * Fixing down migrations * Adding person_content_combined. * Search combined. * Aggregates tables. * Dont rename old tables * Fixing some constraints. * Convert bigints to ints * Forgot a bigint. * Rest of i64 -> i32 * Adding actions id columns. * Fixing connection config. * Formatting smoosh up.sql * Use current_date instead of now * Adding history tables for liked_combined * Upping wal size * Fix clippy * Fixing clippy. * Fixing i64 * Getting rid of let mut conn * Adding the history status table. * Adding published indexes to speed up history. * Adding comment like history scanning. * Fixing schema options setup. * post_read history * person_post_aggregates / read_comments history * post_like history * Fixing conflicts. * Fixing clippy. * Use constant batch_size. * person content combined post and comment history. * Fixing id scanning. * post/comment_actions -> saved_combined history * search history * Post and comment aggregates -> post / comment history. * Uncommenting full history building. * Changing DB_BATCH_SIZE to i64 * Fixing clippy. * Fix index names. * Fixing diff check by removing indexes. * Adding the uplete ignore actions::id columns. * Fixing merge imports. * Fixing submodule update * Try trigger disabling. * Fix clippy * Remove history table, do faster bulk inserts. Smoosh first. Comments about how this fast insert is done is within smoosh comments. * Adding some timings. * Fast person content combined history * Adding search_combined * Fix person saved combined unique names * person_liked_combined * Remove-aggregates * Fixing up.sql issues * Re-building schema.rs * Fixing down migrations. * Removing history updating. * Format sql. * Move postgres logging to customPostgresql.conf * Try using postgres 16-alpine in CI * Speeding up add_report_count. * speed up inbox_combined * Speeding up remove_post_sort_type_enums * Fixing post_sort_type * Speeding up person votes * Fixing wrong conn. * Fixing broken migrations * Remove comment. * Make sure to re-index table after re-enabling indexes. * Removing id columns from actions tables. * Fixing down migrations. * Using create table as for smoosh migration * create_table as for person_content_combined. * Fixing person_content_combined uniques * create table as for search_combined * create table as for liked_combined * create table as for inbox_combined. * Fixing a few score types. * Fixing id positions.
2025-07-23 21:43:23 +00:00
id int GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
recipient_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
Adding combined inbox (#5257) * Renaming person_mention to person_comment_mention. * Finishing up post body mentions. * Combined tables try 2 * Finishing up combined report table. * Fix ts optionals. * Adding tests, triggers, and history updates for report_combined. * Adding profile. * Add cursor pagination to report_combined view (#5244) * add pagination cursor * store timestamp instead of id in cursor (partial) * Revert "store timestamp instead of id in cursor (partial)" This reverts commit 89359dde4bc5fee39fdd2840828330f398444a36. * use paginated query builder * Fixing migration and paged API. * Using dullbananas trigger procedure * Removing pointless list routes, reorganizing tests. * Fixing column XOR check. * Forgot to remove list report actions. * Cleanup. * Use internal tagging. * Fixing api tests. * Adding a few indexes. * Fixing migration name. * Fixing unique constraints. * Addressing PR comments. * Start working on profile combined * Adding views and replaceable schema. * A few changes to profile view. - Separating the profile fetch from its combined content fetch. - Starting to separate saved_only into its own combined view. * Finishing up combined person_saved and person_content. * Fixing api tests. * Moving to api-v4 routes. * Fixing imports. * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Fixing import and fmt. * Fixing null types in postgres. * Comment out err. * Fixing TS issues. * Adding types, fixing allow and blocklist crud. * Starting to work on combined views. * Using dullbananas trigger procedure * Adding the full combined view queries. * Adding tests. * taplo fmt. * Upgrading package.json deps. * Updating pnpm * Most of the bulk work done, need to add tests yet. * Finishing up inbox. * Using assert_length * Fixing sql_format. * Running fmt. * Fixing cargo shear. * Fixing clippy. * Addressing PR comments. * Removing serialization * Removing serialization * Fixing duped trigger. * Remove saved_only test. * Remove pointless post_tags types. * Remove pointless index. * Changing published to saved for person_saved_combined. * Removing comment. * Renaming modlog when_ columns to published. - Fixes #5312 * Adding strum and simplifying imports. * Avoiding clone in map_to_enum * Changing modded_person to other_person. * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Addressing PR comments. * Fixing split. * Revert "Adding strum and simplifying imports." This reverts commit 15f167110721429dd6e465f522250c8beb3d4dd7. * Running fmt. * Using assert + matches instead of filter_map. * Adding listPersonContent check. * Updating lemmy-js-client * Fixing mark all as read route, changing mark read to SuccessResponse. * Adding post body mention api test, fixing api tests. * Fixing route locations, and api tests. --------- Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-01-15 17:51:39 +00:00
read boolean DEFAULT FALSE NOT NULL,
Fast history no background (#5873) * Finishing up post and comment actions * Adding community_actions. * instance and person actions * Fixing person_actions. * Fixing down migrations * Adding person_content_combined. * Search combined. * Aggregates tables. * Dont rename old tables * Fixing some constraints. * Convert bigints to ints * Forgot a bigint. * Rest of i64 -> i32 * Adding actions id columns. * Fixing connection config. * Formatting smoosh up.sql * Use current_date instead of now * Adding history tables for liked_combined * Upping wal size * Fix clippy * Fixing clippy. * Fixing i64 * Getting rid of let mut conn * Adding the history status table. * Adding published indexes to speed up history. * Adding comment like history scanning. * Fixing schema options setup. * post_read history * person_post_aggregates / read_comments history * post_like history * Fixing conflicts. * Fixing clippy. * Use constant batch_size. * person content combined post and comment history. * Fixing id scanning. * post/comment_actions -> saved_combined history * search history * Post and comment aggregates -> post / comment history. * Uncommenting full history building. * Changing DB_BATCH_SIZE to i64 * Fixing clippy. * Fix index names. * Fixing diff check by removing indexes. * Adding the uplete ignore actions::id columns. * Fixing merge imports. * Fixing submodule update * Try trigger disabling. * Fix clippy * Remove history table, do faster bulk inserts. Smoosh first. Comments about how this fast insert is done is within smoosh comments. * Adding some timings. * Fast person content combined history * Adding search_combined * Fix person saved combined unique names * person_liked_combined * Remove-aggregates * Fixing up.sql issues * Re-building schema.rs * Fixing down migrations. * Removing history updating. * Format sql. * Move postgres logging to customPostgresql.conf * Try using postgres 16-alpine in CI * Speeding up add_report_count. * speed up inbox_combined * Speeding up remove_post_sort_type_enums * Fixing post_sort_type * Speeding up person votes * Fixing wrong conn. * Fixing broken migrations * Remove comment. * Make sure to re-index table after re-enabling indexes. * Removing id columns from actions tables. * Fixing down migrations. * Using create table as for smoosh migration * create_table as for person_content_combined. * Fixing person_content_combined uniques * create table as for search_combined * create table as for liked_combined * create table as for inbox_combined. * Fixing a few score types. * Fixing id positions.
2025-07-23 21:43:23 +00:00
published timestamptz NOT NULL DEFAULT now(),
UNIQUE (recipient_id, post_id)
Adding combined inbox (#5257) * Renaming person_mention to person_comment_mention. * Finishing up post body mentions. * Combined tables try 2 * Finishing up combined report table. * Fix ts optionals. * Adding tests, triggers, and history updates for report_combined. * Adding profile. * Add cursor pagination to report_combined view (#5244) * add pagination cursor * store timestamp instead of id in cursor (partial) * Revert "store timestamp instead of id in cursor (partial)" This reverts commit 89359dde4bc5fee39fdd2840828330f398444a36. * use paginated query builder * Fixing migration and paged API. * Using dullbananas trigger procedure * Removing pointless list routes, reorganizing tests. * Fixing column XOR check. * Forgot to remove list report actions. * Cleanup. * Use internal tagging. * Fixing api tests. * Adding a few indexes. * Fixing migration name. * Fixing unique constraints. * Addressing PR comments. * Start working on profile combined * Adding views and replaceable schema. * A few changes to profile view. - Separating the profile fetch from its combined content fetch. - Starting to separate saved_only into its own combined view. * Finishing up combined person_saved and person_content. * Fixing api tests. * Moving to api-v4 routes. * Fixing imports. * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Fixing import and fmt. * Fixing null types in postgres. * Comment out err. * Fixing TS issues. * Adding types, fixing allow and blocklist crud. * Starting to work on combined views. * Using dullbananas trigger procedure * Adding the full combined view queries. * Adding tests. * taplo fmt. * Upgrading package.json deps. * Updating pnpm * Most of the bulk work done, need to add tests yet. * Finishing up inbox. * Using assert_length * Fixing sql_format. * Running fmt. * Fixing cargo shear. * Fixing clippy. * Addressing PR comments. * Removing serialization * Removing serialization * Fixing duped trigger. * Remove saved_only test. * Remove pointless post_tags types. * Remove pointless index. * Changing published to saved for person_saved_combined. * Removing comment. * Renaming modlog when_ columns to published. - Fixes #5312 * Adding strum and simplifying imports. * Avoiding clone in map_to_enum * Changing modded_person to other_person. * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Addressing PR comments. * Fixing split. * Revert "Adding strum and simplifying imports." This reverts commit 15f167110721429dd6e465f522250c8beb3d4dd7. * Running fmt. * Using assert + matches instead of filter_map. * Adding listPersonContent check. * Updating lemmy-js-client * Fixing mark all as read route, changing mark read to SuccessResponse. * Adding post body mention api test, fixing api tests. * Fixing route locations, and api tests. --------- Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-01-15 17:51:39 +00:00
);
-- Updating the history
Fast history no background (#5873) * Finishing up post and comment actions * Adding community_actions. * instance and person actions * Fixing person_actions. * Fixing down migrations * Adding person_content_combined. * Search combined. * Aggregates tables. * Dont rename old tables * Fixing some constraints. * Convert bigints to ints * Forgot a bigint. * Rest of i64 -> i32 * Adding actions id columns. * Fixing connection config. * Formatting smoosh up.sql * Use current_date instead of now * Adding history tables for liked_combined * Upping wal size * Fix clippy * Fixing clippy. * Fixing i64 * Getting rid of let mut conn * Adding the history status table. * Adding published indexes to speed up history. * Adding comment like history scanning. * Fixing schema options setup. * post_read history * person_post_aggregates / read_comments history * post_like history * Fixing conflicts. * Fixing clippy. * Use constant batch_size. * person content combined post and comment history. * Fixing id scanning. * post/comment_actions -> saved_combined history * search history * Post and comment aggregates -> post / comment history. * Uncommenting full history building. * Changing DB_BATCH_SIZE to i64 * Fixing clippy. * Fix index names. * Fixing diff check by removing indexes. * Adding the uplete ignore actions::id columns. * Fixing merge imports. * Fixing submodule update * Try trigger disabling. * Fix clippy * Remove history table, do faster bulk inserts. Smoosh first. Comments about how this fast insert is done is within smoosh comments. * Adding some timings. * Fast person content combined history * Adding search_combined * Fix person saved combined unique names * person_liked_combined * Remove-aggregates * Fixing up.sql issues * Re-building schema.rs * Fixing down migrations. * Removing history updating. * Format sql. * Move postgres logging to customPostgresql.conf * Try using postgres 16-alpine in CI * Speeding up add_report_count. * speed up inbox_combined * Speeding up remove_post_sort_type_enums * Fixing post_sort_type * Speeding up person votes * Fixing wrong conn. * Fixing broken migrations * Remove comment. * Make sure to re-index table after re-enabling indexes. * Removing id columns from actions tables. * Fixing down migrations. * Using create table as for smoosh migration * create_table as for person_content_combined. * Fixing person_content_combined uniques * create table as for search_combined * create table as for liked_combined * create table as for inbox_combined. * Fixing a few score types. * Fixing id positions.
2025-07-23 21:43:23 +00:00
CREATE TABLE inbox_combined AS
Adding combined inbox (#5257) * Renaming person_mention to person_comment_mention. * Finishing up post body mentions. * Combined tables try 2 * Finishing up combined report table. * Fix ts optionals. * Adding tests, triggers, and history updates for report_combined. * Adding profile. * Add cursor pagination to report_combined view (#5244) * add pagination cursor * store timestamp instead of id in cursor (partial) * Revert "store timestamp instead of id in cursor (partial)" This reverts commit 89359dde4bc5fee39fdd2840828330f398444a36. * use paginated query builder * Fixing migration and paged API. * Using dullbananas trigger procedure * Removing pointless list routes, reorganizing tests. * Fixing column XOR check. * Forgot to remove list report actions. * Cleanup. * Use internal tagging. * Fixing api tests. * Adding a few indexes. * Fixing migration name. * Fixing unique constraints. * Addressing PR comments. * Start working on profile combined * Adding views and replaceable schema. * A few changes to profile view. - Separating the profile fetch from its combined content fetch. - Starting to separate saved_only into its own combined view. * Finishing up combined person_saved and person_content. * Fixing api tests. * Moving to api-v4 routes. * Fixing imports. * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Fixing import and fmt. * Fixing null types in postgres. * Comment out err. * Fixing TS issues. * Adding types, fixing allow and blocklist crud. * Starting to work on combined views. * Using dullbananas trigger procedure * Adding the full combined view queries. * Adding tests. * taplo fmt. * Upgrading package.json deps. * Updating pnpm * Most of the bulk work done, need to add tests yet. * Finishing up inbox. * Using assert_length * Fixing sql_format. * Running fmt. * Fixing cargo shear. * Fixing clippy. * Addressing PR comments. * Removing serialization * Removing serialization * Fixing duped trigger. * Remove saved_only test. * Remove pointless post_tags types. * Remove pointless index. * Changing published to saved for person_saved_combined. * Removing comment. * Renaming modlog when_ columns to published. - Fixes #5312 * Adding strum and simplifying imports. * Avoiding clone in map_to_enum * Changing modded_person to other_person. * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Addressing PR comments. * Fixing split. * Revert "Adding strum and simplifying imports." This reverts commit 15f167110721429dd6e465f522250c8beb3d4dd7. * Running fmt. * Using assert + matches instead of filter_map. * Adding listPersonContent check. * Updating lemmy-js-client * Fixing mark all as read route, changing mark read to SuccessResponse. * Adding post body mention api test, fixing api tests. * Fixing route locations, and api tests. --------- Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-01-15 17:51:39 +00:00
SELECT
published,
Fast history no background (#5873) * Finishing up post and comment actions * Adding community_actions. * instance and person actions * Fixing person_actions. * Fixing down migrations * Adding person_content_combined. * Search combined. * Aggregates tables. * Dont rename old tables * Fixing some constraints. * Convert bigints to ints * Forgot a bigint. * Rest of i64 -> i32 * Adding actions id columns. * Fixing connection config. * Formatting smoosh up.sql * Use current_date instead of now * Adding history tables for liked_combined * Upping wal size * Fix clippy * Fixing clippy. * Fixing i64 * Getting rid of let mut conn * Adding the history status table. * Adding published indexes to speed up history. * Adding comment like history scanning. * Fixing schema options setup. * post_read history * person_post_aggregates / read_comments history * post_like history * Fixing conflicts. * Fixing clippy. * Use constant batch_size. * person content combined post and comment history. * Fixing id scanning. * post/comment_actions -> saved_combined history * search history * Post and comment aggregates -> post / comment history. * Uncommenting full history building. * Changing DB_BATCH_SIZE to i64 * Fixing clippy. * Fix index names. * Fixing diff check by removing indexes. * Adding the uplete ignore actions::id columns. * Fixing merge imports. * Fixing submodule update * Try trigger disabling. * Fix clippy * Remove history table, do faster bulk inserts. Smoosh first. Comments about how this fast insert is done is within smoosh comments. * Adding some timings. * Fast person content combined history * Adding search_combined * Fix person saved combined unique names * person_liked_combined * Remove-aggregates * Fixing up.sql issues * Re-building schema.rs * Fixing down migrations. * Removing history updating. * Format sql. * Move postgres logging to customPostgresql.conf * Try using postgres 16-alpine in CI * Speeding up add_report_count. * speed up inbox_combined * Speeding up remove_post_sort_type_enums * Fixing post_sort_type * Speeding up person votes * Fixing wrong conn. * Fixing broken migrations * Remove comment. * Make sure to re-index table after re-enabling indexes. * Removing id columns from actions tables. * Fixing down migrations. * Using create table as for smoosh migration * create_table as for person_content_combined. * Fixing person_content_combined uniques * create table as for search_combined * create table as for liked_combined * create table as for inbox_combined. * Fixing a few score types. * Fixing id positions.
2025-07-23 21:43:23 +00:00
id AS comment_reply_id,
NULL::int AS person_comment_mention_id,
NULL::int AS person_post_mention_id,
NULL::int AS private_message_id
Adding combined inbox (#5257) * Renaming person_mention to person_comment_mention. * Finishing up post body mentions. * Combined tables try 2 * Finishing up combined report table. * Fix ts optionals. * Adding tests, triggers, and history updates for report_combined. * Adding profile. * Add cursor pagination to report_combined view (#5244) * add pagination cursor * store timestamp instead of id in cursor (partial) * Revert "store timestamp instead of id in cursor (partial)" This reverts commit 89359dde4bc5fee39fdd2840828330f398444a36. * use paginated query builder * Fixing migration and paged API. * Using dullbananas trigger procedure * Removing pointless list routes, reorganizing tests. * Fixing column XOR check. * Forgot to remove list report actions. * Cleanup. * Use internal tagging. * Fixing api tests. * Adding a few indexes. * Fixing migration name. * Fixing unique constraints. * Addressing PR comments. * Start working on profile combined * Adding views and replaceable schema. * A few changes to profile view. - Separating the profile fetch from its combined content fetch. - Starting to separate saved_only into its own combined view. * Finishing up combined person_saved and person_content. * Fixing api tests. * Moving to api-v4 routes. * Fixing imports. * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Fixing import and fmt. * Fixing null types in postgres. * Comment out err. * Fixing TS issues. * Adding types, fixing allow and blocklist crud. * Starting to work on combined views. * Using dullbananas trigger procedure * Adding the full combined view queries. * Adding tests. * taplo fmt. * Upgrading package.json deps. * Updating pnpm * Most of the bulk work done, need to add tests yet. * Finishing up inbox. * Using assert_length * Fixing sql_format. * Running fmt. * Fixing cargo shear. * Fixing clippy. * Addressing PR comments. * Removing serialization * Removing serialization * Fixing duped trigger. * Remove saved_only test. * Remove pointless post_tags types. * Remove pointless index. * Changing published to saved for person_saved_combined. * Removing comment. * Renaming modlog when_ columns to published. - Fixes #5312 * Adding strum and simplifying imports. * Avoiding clone in map_to_enum * Changing modded_person to other_person. * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Addressing PR comments. * Fixing split. * Revert "Adding strum and simplifying imports." This reverts commit 15f167110721429dd6e465f522250c8beb3d4dd7. * Running fmt. * Using assert + matches instead of filter_map. * Adding listPersonContent check. * Updating lemmy-js-client * Fixing mark all as read route, changing mark read to SuccessResponse. * Adding post body mention api test, fixing api tests. * Fixing route locations, and api tests. --------- Co-authored-by: dullbananas <dull.bananas0@gmail.com>
2025-01-15 17:51:39 +00:00
FROM
comment_reply
UNION ALL
SELECT
published,
NULL::int,
id,
NULL::int,
NULL::int
FROM
person_comment_mention
UNION ALL
SELECT
published,
NULL::int,
NULL::int,
id,
NULL::int
FROM
person_post_mention
UNION ALL
SELECT
published,
NULL::int,
NULL::int,
NULL::int,
id
FROM
private_message;
Fast history no background (#5873) * Finishing up post and comment actions * Adding community_actions. * instance and person actions * Fixing person_actions. * Fixing down migrations * Adding person_content_combined. * Search combined. * Aggregates tables. * Dont rename old tables * Fixing some constraints. * Convert bigints to ints * Forgot a bigint. * Rest of i64 -> i32 * Adding actions id columns. * Fixing connection config. * Formatting smoosh up.sql * Use current_date instead of now * Adding history tables for liked_combined * Upping wal size * Fix clippy * Fixing clippy. * Fixing i64 * Getting rid of let mut conn * Adding the history status table. * Adding published indexes to speed up history. * Adding comment like history scanning. * Fixing schema options setup. * post_read history * person_post_aggregates / read_comments history * post_like history * Fixing conflicts. * Fixing clippy. * Use constant batch_size. * person content combined post and comment history. * Fixing id scanning. * post/comment_actions -> saved_combined history * search history * Post and comment aggregates -> post / comment history. * Uncommenting full history building. * Changing DB_BATCH_SIZE to i64 * Fixing clippy. * Fix index names. * Fixing diff check by removing indexes. * Adding the uplete ignore actions::id columns. * Fixing merge imports. * Fixing submodule update * Try trigger disabling. * Fix clippy * Remove history table, do faster bulk inserts. Smoosh first. Comments about how this fast insert is done is within smoosh comments. * Adding some timings. * Fast person content combined history * Adding search_combined * Fix person saved combined unique names * person_liked_combined * Remove-aggregates * Fixing up.sql issues * Re-building schema.rs * Fixing down migrations. * Removing history updating. * Format sql. * Move postgres logging to customPostgresql.conf * Try using postgres 16-alpine in CI * Speeding up add_report_count. * speed up inbox_combined * Speeding up remove_post_sort_type_enums * Fixing post_sort_type * Speeding up person votes * Fixing wrong conn. * Fixing broken migrations * Remove comment. * Make sure to re-index table after re-enabling indexes. * Removing id columns from actions tables. * Fixing down migrations. * Using create table as for smoosh migration * create_table as for person_content_combined. * Fixing person_content_combined uniques * create table as for search_combined * create table as for liked_combined * create table as for inbox_combined. * Fixing a few score types. * Fixing id positions.
2025-07-23 21:43:23 +00:00
ALTER TABLE inbox_combined
ADD COLUMN id int PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
ALTER COLUMN published SET NOT NULL,
ADD CONSTRAINT inbox_combined_comment_reply_id_fkey FOREIGN KEY (comment_reply_id) REFERENCES comment_reply ON UPDATE CASCADE ON DELETE CASCADE,
ADD CONSTRAINT inbox_combined_person_comment_mention_id_fkey FOREIGN KEY (person_comment_mention_id) REFERENCES person_comment_mention ON UPDATE CASCADE ON DELETE CASCADE,
ADD CONSTRAINT inbox_combined_person_post_mention_id_fkey FOREIGN KEY (person_post_mention_id) REFERENCES person_post_mention ON UPDATE CASCADE ON DELETE CASCADE,
ADD CONSTRAINT inbox_combined_private_message_id_fkey FOREIGN KEY (private_message_id) REFERENCES private_message ON UPDATE CASCADE ON DELETE CASCADE,
ADD UNIQUE (comment_reply_id),
ADD UNIQUE (person_comment_mention_id),
ADD UNIQUE (person_post_mention_id),
ADD UNIQUE (private_message_id),
ADD CONSTRAINT inbox_combined_check CHECK (num_nonnulls (comment_reply_id, person_comment_mention_id, person_post_mention_id, private_message_id) = 1);
CREATE INDEX idx_inbox_combined_published ON inbox_combined (published DESC, id DESC);
CREATE INDEX idx_inbox_combined_published_asc ON inbox_combined (reverse_timestamp_sort (published) DESC, id DESC);