1 # frozen_string_literal: true
 
   3 # == Schema Information
 
   5 # Table name: user_roles
 
   7 #  id         :integer          not null, primary key
 
   8 #  user_id    :bigint           not null
 
  10 #  updated_at :datetime
 
  12 #  granter_id :bigint           not null
 
  16 #  user_roles_id_role_unique  (user_id,role) UNIQUE
 
  20 #  user_roles_granter_id_fkey  (granter_id => users.id)
 
  21 #  user_roles_user_id_fkey     (user_id => users.id)
 
  24 class UserRole < ApplicationRecord
 
  26   belongs_to :granter, :class_name => "User"
 
  28   ALL_ROLES = %w[administrator moderator importer].freeze
 
  30   validates :role, :inclusion => ALL_ROLES, :uniqueness => { :scope => :user_id }