discourse/app/models/user_custom_field.rb
David Taylor 993f94d54c
DEV: Load all bundled plugins when running annotate:clean (#39978)
Core models often pick up associations and columns from bundled plugins
(e.g. `qa_vote_count` from `discourse-post-voting`, locale-detection
indexes from `discourse-ai`), and the schema blocks at the bottom of
`app/models/*.rb` should reflect those.

`annotate:clean` now defaults `LOAD_PLUGINS` to the bundled plugin list
(`script/list_bundled_plugins`) — the result is the same regardless of
which extra plugins happen to be checked out under `plugins/`. Setting
`LOAD_PLUGINS` explicitly still overrides.

Includes the resulting one-off annotation regen.
2026-05-13 17:19:15 +01:00

38 lines
1.4 KiB
Ruby
Vendored

# frozen_string_literal: true
class UserCustomField < ActiveRecord::Base
include CustomField
belongs_to :user
scope :searchable,
-> do
joins(
"INNER JOIN user_fields ON user_fields.id = REPLACE(user_custom_fields.name, 'user_field_', '')::INTEGER",
).where("user_fields.searchable = TRUE").where(
"user_custom_fields.name ~ ?",
'^user_field_\\d+$',
)
end
end
# == Schema Information
#
# Table name: user_custom_fields
#
# id :integer not null, primary key
# name :string(256) not null
# value :text
# created_at :datetime not null
# updated_at :datetime not null
# user_id :integer not null
#
# Indexes
#
# idx_user_custom_fields_last_reminded_at (name,user_id) UNIQUE WHERE ((name)::text = 'last_reminded_at'::text)
# idx_user_custom_fields_on_holiday (name,user_id) UNIQUE WHERE ((name)::text = 'on_holiday'::text)
# idx_user_custom_fields_remind_assigns_frequency (name,user_id) UNIQUE WHERE ((name)::text = 'remind_assigns_frequency'::text)
# idx_user_custom_fields_user_notes_count (name,user_id) UNIQUE WHERE ((name)::text = 'user_notes_count'::text)
# index_user_custom_fields_on_user_id_and_name (user_id,name)
# index_user_custom_fields_on_value (value) UNIQUE WHERE ((name)::text = 'ai-stream-conversation-unique-id'::text)
#