summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-10-19 04:44:41 +0100
committerNick Thomas <nick@gitlab.com>2018-11-05 01:40:29 +0000
commit270155d655bec91c3ae636e158b25fdb5bd03b45 (patch)
tree2b7059d69cd3d4f1b443817daae0659562ba0fc0 /app
parentf760c1cd17881c8aef3a33a3b43db54673db8111 (diff)
downloadgitlab-ce-270155d655bec91c3ae636e158b25fdb5bd03b45.tar.gz
Start tracking pool repositories
Diffstat (limited to 'app')
-rw-r--r--app/models/pool_repository.rb22
-rw-r--r--app/models/project.rb1
2 files changed, 23 insertions, 0 deletions
diff --git a/app/models/pool_repository.rb b/app/models/pool_repository.rb
new file mode 100644
index 00000000000..8ef74539209
--- /dev/null
+++ b/app/models/pool_repository.rb
@@ -0,0 +1,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
diff --git a/app/models/project.rb b/app/models/project.rb
index fa995b5b061..872bea46e7c 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -124,6 +124,7 @@ class Project < ActiveRecord::Base
alias_attribute :title, :name
# Relations
+ belongs_to :pool_repository
belongs_to :creator, class_name: 'User'
belongs_to :group, -> { where(type: 'Group') }, foreign_key: 'namespace_id'
belongs_to :namespace