mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 13:06:56 +08:00
FIX: Make chat editor IDs not null (#18903)
Follow up to 766bcbc6840c9d665055441bcd77616b3a96e10e Makes ChatMessage.last_editor_id and ChatMessageRevision.user_id NOT NULL since they are always filled in now and the last commit had a migration to backfill this data.
This commit is contained in:
@ -210,7 +210,7 @@ end
|
|||||||
# message :text
|
# message :text
|
||||||
# cooked :text
|
# cooked :text
|
||||||
# cooked_version :integer
|
# cooked_version :integer
|
||||||
# last_editor_id :integer
|
# last_editor_id :integer not null
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
@ -15,7 +15,7 @@ end
|
|||||||
# new_message :text not null
|
# new_message :text not null
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# user_id :integer
|
# user_id :integer not null
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class MakeChatEditorIdsNotNull < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
change_column_null :chat_messages, :last_editor_id, false
|
||||||
|
change_column_null :chat_message_revisions, :user_id, false
|
||||||
|
end
|
||||||
|
end
|
@ -93,9 +93,12 @@ class Chat::MessageMover
|
|||||||
destination_channel_id: destination_channel.id,
|
destination_channel_id: destination_channel.id,
|
||||||
}
|
}
|
||||||
moved_message_ids = DB.query_single(<<~SQL, query_args)
|
moved_message_ids = DB.query_single(<<~SQL, query_args)
|
||||||
INSERT INTO chat_messages(chat_channel_id, user_id, message, cooked, cooked_version, created_at, updated_at)
|
INSERT INTO chat_messages(
|
||||||
|
chat_channel_id, user_id, last_editor_id, message, cooked, cooked_version, created_at, updated_at
|
||||||
|
)
|
||||||
SELECT :destination_channel_id,
|
SELECT :destination_channel_id,
|
||||||
user_id,
|
user_id,
|
||||||
|
last_editor_id,
|
||||||
message,
|
message,
|
||||||
cooked,
|
cooked,
|
||||||
cooked_version,
|
cooked_version,
|
||||||
|
@ -47,6 +47,7 @@ Fabricator(:chat_message_revision) do
|
|||||||
chat_message { Fabricate(:chat_message) }
|
chat_message { Fabricate(:chat_message) }
|
||||||
old_message { "something old" }
|
old_message { "something old" }
|
||||||
new_message { "something new" }
|
new_message { "something new" }
|
||||||
|
user { |attrs| attrs[:chat_message].user }
|
||||||
end
|
end
|
||||||
|
|
||||||
Fabricator(:reviewable_chat_message) do
|
Fabricator(:reviewable_chat_message) do
|
||||||
|
@ -36,7 +36,8 @@ describe Jobs::ChatChannelDelete do
|
|||||||
)
|
)
|
||||||
|
|
||||||
revision_message = messages.sample
|
revision_message = messages.sample
|
||||||
ChatMessageRevision.create(
|
Fabricate(
|
||||||
|
:chat_message_revision,
|
||||||
chat_message: revision_message,
|
chat_message: revision_message,
|
||||||
old_message: "some old message",
|
old_message: "some old message",
|
||||||
new_message: revision_message.message,
|
new_message: revision_message.message,
|
||||||
|
@ -58,7 +58,7 @@ describe Jobs::ChatNotifyMentioned do
|
|||||||
|
|
||||||
it "does nothing if there is a newer version of the message" do
|
it "does nothing if there is a newer version of the message" do
|
||||||
message = create_chat_message
|
message = create_chat_message
|
||||||
ChatMessageRevision.create!(chat_message: message, old_message: "a", new_message: "b")
|
Fabricate(:chat_message_revision, chat_message: message, old_message: "a", new_message: "b")
|
||||||
|
|
||||||
PostAlerter.expects(:push_notification).never
|
PostAlerter.expects(:push_notification).never
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user