DEV: Add ChatThread model and DB table, and ChatMessage reference (#20106)

This new table will be used to automatically group replies
for messages into one place. In future additional functionality
will be built around the thread, like pinning messages, changing
the title, etc., the columns are just the main ones needed at first.
The columns are not prefixed with `chat_*` e.g. `chat_channel` since
this is redundant and just adds duplication everywhere, we want to
move away from this generally within chat.
This commit is contained in:
Martin Brennan
2023-02-01 13:50:38 +10:00
committed by GitHub
parent 9d55e2a939
commit e7b39e2fc1
4 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,24 @@
# frozen_string_literal: true
class CreateChatThreadingModels < ActiveRecord::Migration[7.0]
def change
create_table :chat_threads do |t|
t.bigint :channel_id, null: false
t.bigint :original_message_id, null: false
t.bigint :original_message_user_id, null: false
t.integer :status, null: false, default: 0
t.string :title, null: true
t.timestamps
end
add_index :chat_threads, :channel_id
add_index :chat_threads, :original_message_id
add_index :chat_threads, :original_message_user_id
add_index :chat_threads, :status
add_index :chat_threads, %i[channel_id status]
add_column :chat_messages, :thread_id, :bigint, null: true
add_index :chat_messages, :thread_id
end
end