require "jennifer/model/base"
require "jennifer/model/authentication"

module ContainerMom::Models
  class User < Jennifer::Model::Base
    include Jennifer::Model::Authentication
    with_timestamps

    mapping(
      id: Primary64,
      email: String,
      password_hash: String,
      name: String?,
      created_at: Time?,
      updated_at: Time?
    )

    has_many :api_tokens, ApiToken, foreign: :user_id
    has_many :container_deployments, ContainerDeployment, foreign: :user_id

    validates_presence :email
    validates_presence :password_hash
    validates_uniqueness :email
  end
end
