2020-05-24 23:13:21 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# ProjectRepositoryStorageMove are details of repository storage moves for a
|
|
|
|
# project. For example, moving a project to another gitaly node to help
|
|
|
|
# balance storage capacity.
|
|
|
|
class ProjectRepositoryStorageMove < ApplicationRecord
|
2021-02-22 17:27:13 +05:30
|
|
|
extend ::Gitlab::Utils::Override
|
|
|
|
include RepositoryStorageMovable
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
belongs_to :container, class_name: 'Project', inverse_of: :repository_storage_moves, foreign_key: :project_id
|
|
|
|
alias_attribute :project, :container
|
|
|
|
scope :with_projects, -> { includes(container: :route) }
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
override :update_repository_storage
|
|
|
|
def update_repository_storage(new_storage)
|
|
|
|
container.update_column(:repository_storage, new_storage)
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
override :schedule_repository_storage_update_worker
|
|
|
|
def schedule_repository_storage_update_worker
|
|
|
|
ProjectUpdateRepositoryStorageWorker.perform_async(
|
|
|
|
project_id,
|
|
|
|
destination_storage_name,
|
|
|
|
id
|
|
|
|
)
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
private
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
override :error_key
|
|
|
|
def error_key
|
|
|
|
:project
|
2020-06-23 00:09:42 +05:30
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|