mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-21 19:42:54 +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.
37 lines
955 B
Ruby
Vendored
37 lines
955 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class UserStatus < ActiveRecord::Base
|
|
MAX_DESCRIPTION_LENGTH = 100
|
|
|
|
belongs_to :user
|
|
|
|
validate :emoji_exists
|
|
validates :description, length: { maximum: MAX_DESCRIPTION_LENGTH }
|
|
validate :ends_at_greater_than_set_at,
|
|
if: Proc.new { |t| t.will_save_change_to_set_at? || t.will_save_change_to_ends_at? }
|
|
|
|
def expired?
|
|
ends_at && ends_at < Time.zone.now
|
|
end
|
|
|
|
def emoji_exists
|
|
errors.add(:emoji, :invalid) if emoji && !Emoji.exists?(emoji)
|
|
end
|
|
|
|
def ends_at_greater_than_set_at
|
|
if ends_at && set_at > ends_at
|
|
errors.add(:ends_at, I18n.t("user_status.errors.ends_at_should_be_greater_than_set_at"))
|
|
end
|
|
end
|
|
end
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: user_statuses
|
|
#
|
|
# description :string not null
|
|
# emoji :string not null
|
|
# ends_at :datetime
|
|
# set_at :datetime not null
|
|
# user_id :integer not null, primary key
|
|
#
|