discourse/plugins/chat/app/models/chat/user_chat_thread_membership.rb
Martin Brennan cb87ef52de
FIX: Backfill chat thread memberships (#21971)
Since we created user_chat_thread_memberships in
cc2570f we haven't
yet backfilled it for users who previously sent a message in
in threads -- this migration creates the UserChatThreadMemberships
needed for those threads, making sure the last read message id
is accurate for those participants.
2023-06-14 13:54:51 +10:00

31 lines
924 B
Ruby

# frozen_string_literal: true
module Chat
class UserChatThreadMembership < ActiveRecord::Base
self.table_name = "user_chat_thread_memberships"
belongs_to :user
belongs_to :last_read_message, class_name: "Chat::Message", optional: true
belongs_to :thread, class_name: "Chat::Thread", foreign_key: :thread_id
enum :notification_level, Chat::NotificationLevels.all
end
end
# == Schema Information
#
# Table name: user_chat_thread_memberships
#
# id :bigint not null, primary key
# user_id :bigint not null
# thread_id :bigint not null
# last_read_message_id :bigint
# notification_level :integer default("tracking"), not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# user_chat_thread_unique_memberships (user_id,thread_id) UNIQUE
#