diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-21 21:10:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-21 21:10:08 +0300 |
commit | 5d41ea8c8e83ff6054ba4303ec8dc9bc33556602 (patch) | |
tree | f69079c9fac34f1e5e785d1f18d2f9ad339e4cbc /app/models/projects | |
parent | a09c6d7e91de9abab7e2ea8dffce1cbb89bf95d8 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/projects')
-rw-r--r-- | app/models/projects/import_export/relation_export.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/models/projects/import_export/relation_export.rb b/app/models/projects/import_export/relation_export.rb index 0a31e525ac2..15198049f87 100644 --- a/app/models/projects/import_export/relation_export.rb +++ b/app/models/projects/import_export/relation_export.rb @@ -3,6 +3,20 @@ module Projects module ImportExport class RelationExport < ApplicationRecord + DESIGN_REPOSITORY_RELATION = 'design_repository' + LFS_OBJECTS_RELATION = 'lfs_objects' + REPOSITORY_RELATION = 'repository' + ROOT_RELATION = 'project' + SNIPPETS_REPOSITORY_RELATION = 'snippets_repository' + UPLOADS_RELATION = 'uploads' + WIKI_REPOSITORY_RELATION = 'wiki_repository' + + EXTRA_RELATION_LIST = [ + DESIGN_REPOSITORY_RELATION, LFS_OBJECTS_RELATION, REPOSITORY_RELATION, ROOT_RELATION, + SNIPPETS_REPOSITORY_RELATION, UPLOADS_RELATION, WIKI_REPOSITORY_RELATION + ].freeze + private_constant :EXTRA_RELATION_LIST + self.table_name = 'project_relation_exports' belongs_to :project_export_job @@ -17,6 +31,33 @@ module Projects validates :project_export_job, presence: true validates :relation, presence: true, length: { maximum: 255 }, uniqueness: { scope: :project_export_job_id } validates :status, numericality: { only_integer: true }, presence: true + + scope :by_relation, -> (relation) { where(relation: relation) } + + state_machine :status, initial: :queued do + state :queued, value: 0 + state :started, value: 1 + state :finished, value: 2 + state :failed, value: 3 + + event :start do + transition queued: :started + end + + event :finish do + transition started: :finished + end + + event :fail_op do + transition [:queued, :started] => :failed + end + end + + def self.relation_names_list + project_tree_relation_names = ::Gitlab::ImportExport::Reader.new(shared: nil).project_relation_names.map(&:to_s) + + project_tree_relation_names + EXTRA_RELATION_LIST + end end end end |