class EmployeeCategoryGroup < ApplicationRecord
  include Base::EmployeeCategoryGroup

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

  has_many :categories, class_name: 'EmployeeCategory', foreign_key: :UCGID, inverse_of: :group,
    dependent: :destroy
  has_many :employee_category_users, through: :categories

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

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