mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-26 06:38:28 +08:00
`.annotaterb.yml` has carried `classified_sort: true` since the project
switched from `annotate` to `annotaterb` (commit 0eab7daea4, July 2025),
but annotaterb's default behaviour is to compare the existing schema
block against what it would generate and skip the rewrite when the
column list matches — even when the *ordering* of those columns differs.
The result is that models which haven't had a schema change since the
config landed never get reordered, and `classified_sort` drift
accumulates indefinitely.
`--force` makes annotaterb always rewrite, so a single `bin/rake
annotate:clean` run brings every model into the canonical format and
keeps them there. Every schema block is now grouped primary-key →
regular columns → timestamps → foreign keys (alphabetical within each
group). Pure annotation comment change — no code modifications.
Also cleans up the rake task to avoid string interpolation for `system`
calls.
71 lines
2.1 KiB
Ruby
Vendored
71 lines
2.1 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class GroupArchivedMessage < ActiveRecord::Base
|
|
belongs_to :group
|
|
belongs_to :topic
|
|
|
|
def self.move_to_inbox!(group_id, topic, opts = {})
|
|
topic_id = topic.id
|
|
|
|
GroupArchivedMessage.where(group_id: group_id, topic_id: topic_id).destroy_all
|
|
|
|
trigger(:move_to_inbox, group_id, topic_id)
|
|
MessageBus.publish("/topic/#{topic_id}", { type: "move_to_inbox" }, group_ids: [group_id])
|
|
publish_topic_tracking_state(topic, group_id, opts[:acting_user_id])
|
|
|
|
Jobs.enqueue(
|
|
:group_pm_update_summary,
|
|
group_id: group_id,
|
|
topic_id: topic_id,
|
|
acting_user_id: opts[:acting_user_id],
|
|
)
|
|
end
|
|
|
|
def self.archive!(group_id, topic, opts = {})
|
|
topic_id = topic.id
|
|
|
|
GroupArchivedMessage.where(group_id: group_id, topic_id: topic_id).destroy_all
|
|
GroupArchivedMessage.create!(group_id: group_id, topic_id: topic_id)
|
|
|
|
trigger(:archive_message, group_id, topic_id)
|
|
MessageBus.publish("/topic/#{topic_id}", { type: "archived" }, group_ids: [group_id])
|
|
publish_topic_tracking_state(topic, group_id, opts[:acting_user_id])
|
|
|
|
Jobs.enqueue(
|
|
:group_pm_update_summary,
|
|
group_id: group_id,
|
|
topic_id: topic_id,
|
|
acting_user_id: opts[:acting_user_id],
|
|
)
|
|
end
|
|
|
|
def self.trigger(event, group_id, topic_id)
|
|
group = Group.find_by(id: group_id)
|
|
topic = Topic.find_by(id: topic_id)
|
|
DiscourseEvent.trigger(event, group: group, topic: topic) if group && topic
|
|
end
|
|
|
|
def self.publish_topic_tracking_state(topic, group_id, acting_user_id = nil)
|
|
PrivateMessageTopicTrackingState.publish_group_archived(
|
|
topic: topic,
|
|
group_id: group_id,
|
|
acting_user_id: acting_user_id,
|
|
)
|
|
end
|
|
private_class_method :publish_topic_tracking_state
|
|
end
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: group_archived_messages
|
|
#
|
|
# id :integer not null, primary key
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# group_id :integer not null
|
|
# topic_id :integer not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_group_archived_messages_on_group_id_and_topic_id (group_id,topic_id) UNIQUE
|
|
#
|