class CompanyAdditionalGroup < ApplicationRecord
  include Base::CompanyAdditionalGroup

  default_scope { where(type: 2) }

  associations_for legacy: true do |a|
    a.belongs_to :school
  end

  has_many :fields, class_name: 'CompanyAdditionalField', foreign_key: :CSGID,
    dependent: :restrict_with_error, inverse_of: :group

  validates :name, presence: true, length: { maximum: 16 }
  validates :description, length: { maximum: 64 }

  scope :ordered, -> { order(:name) }
end
