summaryrefslogtreecommitdiff
path: root/app/models/pool_repository.rb
blob: 8ef74539209912bb18dab71fe872ab569fc8ae35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

class PoolRepository < ActiveRecord::Base
  POOL_PREFIX = '@pools'

  belongs_to :shard
  validates :shard, presence: true

  # For now, only pool repositories are tracked in the database. However, we may
  # want to add other repository types in the future
  self.table_name = 'repositories'

  has_many :pool_member_projects, class_name: 'Project', foreign_key: :pool_repository_id

  def shard_name
    shard&.name
  end

  def shard_name=(name)
    self.shard = Shard.by_name(name)
  end
end