discourse/plugins/chat/db/migrate
Andrei Prigorshnev fbd24fa6ae
DEV: Allow chat mentions to have several notifications (#24874)
This PR is a reworked version of https://github.com/discourse/discourse/pull/24670.

In chat, we need the ability to have several notifications per `chat_mention`. 
Currently, we have one_to_one relationship between `chat_mentions` and `notifications`:

d7a09fb08d/plugins/chat/app/models/chat/mention.rb (L9)

We want to have one_to_many relationship. This PR implements that by introducing 
a join table between `chat_mentions` and `notifications`.

The main motivation for this is that we want to solve some performance problems 
with mentions that we're having now. Let's say a user sends a message with @ all 
in a channel with 50 members, we do two things in this case at the moment:

- create 50 chat_mentions
- create 50 notifications

We don't want to change how notifications work in core, but we want to be more 
efficient in chat, and create only 1 `chat_mention` which would link to 50 notifications. 
Also note, that on the side of notifications, having a lot of notifications is not so 
big problem, because notifications processing can be queued.

Apart from improving performance, this change will make the code design better.

Note that I've marked the old `chat_mention.notification_id` column as ignored, but 
I'm not deleting it in this PR. We'll delete it later in https://github.com/discourse/discourse/pull/24800.
2023-12-19 18:53:00 +04:00
..
20210225230057_create_chat_tables.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20210403025854_add_action_code_to_topic_chat_message.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20210706214013_rename_topic_chats_to_chat_channels.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20210729134042_create_chat_message_revisions.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20210730134847_create_user_chat_channel_last_read.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20210812145801_create_direct_message_tables.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20210813141741_add_timestamps_to_chat_channels.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20210819202912_create_incoming_chat_webhooks.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20210823160357_create_chat_webhook_events.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20210901130308_create_user_chat_channel_membership.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20210930144333_add_chat_enabled_to_user_options.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20211022151713_create_chat_message_post_connections.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20211029145508_add_chat_isolated_to_user_options.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20211104141254_add_only_chat_push_notifications_to_user_options.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20211119142000_add_cooked_to_chat_messages.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20211129171229_create_chat_uploads.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20211201171813_create_chat_reactions.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20211210191830_create_chat_mentions.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20211213150607_add_chat_sound_to_user_options.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20211217221026_add_name_to_chat_channel.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20211222153716_add_description_to_chat_channels.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220104051326_change_chat_channels_timestamp_columns_to_timestamp_type.rb DEV: Promote historic post_deploy migrations (#19496) 2022-12-19 20:45:37 +02:00
20220119170535_add_chat_retention_fields_to_user_options.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220203204002_create_chat_drafts_table.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220203204003_migrate_drafts_to_chat_drafts.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220218023859_add_status_to_chat_channel.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220228051724_create_chat_channel_archive_table.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220308165620_add_user_count_to_chat_channel.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220309174820_add_last_message_created_at_to_chat_channels.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220321235638_drop_chat_message_post_connections_table.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20220324062937_ignore_channel_wide_mention_to_user_options.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220328142120_create_user_chat_message_statuses.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220504080457_drop_old_chat_message_post_id_action_code_columns.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20220516142658_remove_email_statuses_table.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20220518140004_track_last_unread_mention_when_emailed.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220518180642_remove_user_option_last_emailed_at.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20220526135414_remove_corrupted_last_read_message_id.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20220531105951_drop_user_chat_channel_last_reads.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20220629190633_auto_join_users_to_channels.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220630074200_drop_chat_isolated_from_user_options.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20220701195731_convert_chatable_topics_to_categories.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20220706114835_add_join_mode_to_channel_memberships.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220729032237_add_index_to_chat_message_created_at.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220802014549_disable_chat_uploads_if_secure_media_enabled.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20220901034107_add_user_count_stale_to_channel.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20221004122254_delete_reviewables_targetting_deleted_chat_messages.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20221005143622_add_type_to_chat_channel.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20221014005208_add_slug_column_to_chat_channel.rb DEV: Move discourse-chat to the core repo. (#18776) 2022-11-02 10:41:30 -03:00
20221018091412_migrate_chat_channels.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20221027090832_migrate_dm_channels.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20221101061319_add_last_editor_id_to_chat_messages.rb FIX: Add editing user ids to ChatMessage and ChatMessageRevision (#18877) 2022-11-07 09:04:47 +10:00
20221104054957_backfill_channel_slugs.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20221107034541_make_chat_editor_ids_not_null.rb FIX: Migrate values before adding a not null constraint. (#18940) 2022-11-08 16:11:03 -03:00
20221117052348_truncate_chat_messages_over_max_length.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20221117142910_delete_orphaned_channels.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20221118104708_add_allow_channel_wide_mentions_to_chat_channels.rb FEATURE: channels can allow/disallow @all/@here mentions (#19317) 2022-12-05 17:03:51 +01:00
20221122070108_save_chat_allowed_groups_site_setting.rb DEV: Apply syntax_tree formatting to plugins/* 2023-01-07 11:11:37 +00:00
20221201024458_make_channel_slugs_unique_with_index.rb FIX: Ensure chat channel slug uniqueness at DB level (#19277) 2022-12-02 11:15:43 +10:00
20221201032830_drop_tmp_chat_slug_tables.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20221201035918_add_slug_unique_index_for_chat_channels.rb FIX: Ensure chat channel slug uniqueness at DB level (#19277) 2022-12-02 11:15:43 +10:00
20221202032006_add_chat_message_count_to_chat_channels.rb DEV: Add messages_count to ChatChannel table (#19295) 2022-12-06 08:40:46 +10:00
20221202043755_update_chat_channel_message_counts.rb DEV: Promote historic post_deploy migrations 2023-07-26 10:36:37 +02:00
20221219082223_add_index_to_chat_messages.rb DEV: Make recent creation of chat index idempotent (#19603) 2022-12-23 10:23:57 +08:00
20230123020036_move_chat_uploads_to_upload_references.rb DEV: Use UploadReference instead of ChatUpload in chat (#19947) 2023-01-24 13:28:21 +10:00
20230130053144_add_threading_enabled_to_chat_channels.rb DEV: Start threading for chat (#20060) 2023-01-31 10:01:47 +10:00
20230201012734_create_chat_threading_models.rb DEV: Add ChatThread model and DB table, and ChatMessage reference (#20106) 2023-02-01 13:50:38 +10:00
20230228062442_add_chat_header_indicator_preference.rb FEATURE: Chat header icon indicator preference (#20474) 2023-03-01 11:01:44 +10:00
20230411012630_add_thread_not_deleted_index_chat_messages.rb DEV: Chat thread reply counter cache (#21050) 2023-04-11 15:40:25 +10:00
20230411023246_add_chat_message_replies_count_to_chat_threads.rb DEV: Chat thread reply counter cache (#21050) 2023-04-11 15:40:25 +10:00
20230510142249_add_user_chat_thread_memberships.rb DEV: Create UserChatThreadMembership table and model (#21481) 2023-05-10 17:19:48 +02:00
20230607091233_backfill_thread_memberships.rb FIX: Backfill chat thread memberships (#21971) 2023-06-14 13:54:51 +10:00
20230627044755_add_last_viewed_at_to_user_chat_channel_memberships.rb FEATURE: Track last_viewed_at datetime for channel members (#22294) 2023-06-29 09:22:17 +10:00
20230707025733_add_last_message_id_to_channel_and_thread.rb DEV: Add last_message_id to channel and thread (#22488) 2023-07-13 10:28:11 +10:00
20230707082645_backfill_chat_channel_and_thread_last_message_ids.rb DEV: Add last_message_id to channel and thread (#22488) 2023-07-13 10:28:11 +10:00
20230721025249_remove_experimental_site_setting_for_threads.rb DEV: Remove experimental setting row for chat threads (#22730) 2023-07-27 15:29:28 +02:00
20230722124044_add_chat_separate_sidebar_mode_user_option.rb FEATURE: implements user based sidebar mode (#23078) 2023-08-18 20:33:07 +02:00
20231006160650_add_group_field_to_direct_message_channels.rb FEATURE: introduces group channels (#24288) 2023-11-10 11:29:28 +01:00
20231006161051_set_multiusers_direct_message_channels_as_group.rb FEATURE: introduces group channels (#24288) 2023-11-10 11:29:28 +01:00
20231110214451_adds_thread_id_to_chat_drafts.rb FEATURE: implements drafts for threads (#24483) 2023-11-22 11:54:23 +01:00
20231207135641_add_user_chat_thread_memberships_on_thread_id_user_id_index.rb FEATURE: my threads page (#24771) 2023-12-11 07:38:07 +01:00
20231214180000_add_chat_mention_notifications.rb DEV: Allow chat mentions to have several notifications (#24874) 2023-12-19 18:53:00 +04:00
20231214180001_update_relationship_between_chat_mentions_and_notifications.rb DEV: Allow chat mentions to have several notifications (#24874) 2023-12-19 18:53:00 +04:00