mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 03:23:50 +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.
40 lines
1.2 KiB
Ruby
Vendored
40 lines
1.2 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
class AiArtifactVersion < ActiveRecord::Base
|
|
belongs_to :ai_artifact
|
|
validates :html, length: { maximum: 65_535 }
|
|
validates :css, length: { maximum: 65_535 }
|
|
validates :js, length: { maximum: 65_535 }
|
|
|
|
# used when generating test cases
|
|
def write_to(path)
|
|
css_path = "#{path}/main.css"
|
|
html_path = "#{path}/main.html"
|
|
js_path = "#{path}/main.js"
|
|
instructions_path = "#{path}/instructions.txt"
|
|
|
|
File.write(css_path, css)
|
|
File.write(html_path, html)
|
|
File.write(js_path, js)
|
|
File.write(instructions_path, change_description)
|
|
end
|
|
end
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: ai_artifact_versions
|
|
#
|
|
# id :bigint not null, primary key
|
|
# change_description :string
|
|
# css :string(65535)
|
|
# html :string(65535)
|
|
# js :string(65535)
|
|
# metadata :jsonb
|
|
# version_number :integer not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# ai_artifact_id :bigint not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_ai_artifact_versions_on_ai_artifact_id_and_version_number (ai_artifact_id,version_number) UNIQUE
|
|
#
|