Class: Gitlab::BackgroundMigration::BackfillProjectRepositories::Project

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Routable
Defined in:
lib/gitlab/background_migration/backfill_project_repositories.rb

Overview

Project model

Constant Summary collapse

HASHED_STORAGE_FEATURES =
{
  repository: 1,
  attachments: 2
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Routable

#build_full_path, #full_path, #has_parent?

Class Method Details

.left_outer_join_project_repositoryObject



165
166
167
168
169
170
171
172
173
# File 'lib/gitlab/background_migration/backfill_project_repositories.rb', line 165

def left_outer_join_project_repository
  projects_table = Project.arel_table
  repository_table = ProjectRepository.arel_table

  projects_table
    .join(repository_table, Arel::Nodes::OuterJoin)
    .on(projects_table[:id].eq(repository_table[:project_id]))
    .join_sources
end

.on_hashed_storageObject



150
151
152
153
# File 'lib/gitlab/background_migration/backfill_project_repositories.rb', line 150

def on_hashed_storage
  where(Project.arel_table[:storage_version]
    .gteq(HASHED_STORAGE_FEATURES[:repository]))
end

.on_legacy_storageObject



155
156
157
158
# File 'lib/gitlab/background_migration/backfill_project_repositories.rb', line 155

def on_legacy_storage
  where(Project.arel_table[:storage_version].eq(nil)
    .or(Project.arel_table[:storage_version].eq(0)))
end

.without_project_repositoryObject



160
161
162
163
# File 'lib/gitlab/background_migration/backfill_project_repositories.rb', line 160

def without_project_repository
  joins(left_outer_join_project_repository)
    .where(ProjectRepository.arel_table[:project_id].eq(nil))
end

Instance Method Details

#hashed_storage?Boolean

Returns:

  • (Boolean)


185
186
187
188
# File 'lib/gitlab/background_migration/backfill_project_repositories.rb', line 185

def hashed_storage?
  self.storage_version &&
    self.storage_version >= HASHED_STORAGE_FEATURES[:repository]
end

#storageObject



176
177
178
179
180
181
182
183
# File 'lib/gitlab/background_migration/backfill_project_repositories.rb', line 176

def storage
  @storage ||=
    if hashed_storage?
      Storage::Hashed.new(self)
    else
      Storage::LegacyProject.new(self)
    end
end