diff options
author | Stan Hu <stanhu@gmail.com> | 2019-01-07 23:31:30 -0800 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2019-01-11 15:36:51 +0100 |
commit | 618875c58c50b0c9dcfa90033ebe975004f401a2 (patch) | |
tree | 0243d7b21f0f6331b7c4610ba510468209622e87 /lib | |
parent | 6b2f81f6078e96f081154c50dc25e54fe7c09d6f (diff) | |
download | gitlab-ce-618875c58c50b0c9dcfa90033ebe975004f401a2.tar.gz |
Fix duplicate disk path in Backfill ProjectRepos
On GitLab.com, we saw numerous duplicate disk entry inserts because
the migration was not taking the routes table into account. We now
implement this in the migration to be consistent.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56061
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/background_migration/backfill_project_repositories.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/gitlab/background_migration/backfill_project_repositories.rb b/lib/gitlab/background_migration/backfill_project_repositories.rb index aaf520d70f6..2a7f10c21e1 100644 --- a/lib/gitlab/background_migration/backfill_project_repositories.rb +++ b/lib/gitlab/background_migration/backfill_project_repositories.rb @@ -83,7 +83,7 @@ module Gitlab extend ActiveSupport::Concern def full_path - @full_path ||= build_full_path + route&.path || build_full_path end def build_full_path @@ -99,6 +99,9 @@ module Gitlab end end + class Route < ActiveRecord::Base + end + # Namespace model. class Namespace < ActiveRecord::Base self.table_name = 'namespaces' @@ -110,6 +113,10 @@ module Gitlab has_many :projects, inverse_of: :parent has_many :namespaces, inverse_of: :parent + + def route + Route.find_by(source_type: 'Namespace', source_id: self.id) + end end # ProjectRegistry model @@ -165,6 +172,10 @@ module Gitlab end end + def route + Route.find_by(source_type: 'Project', source_id: self.id) + end + def storage @storage ||= if hashed_storage? |