Welcome to mirror list, hosted at ThFree Co, Russian Federation.

export_batch.rb « bulk_imports « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9d34dae12d03d8b2a22a3388b8b7db4cea6d6f16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module BulkImports
  class ExportBatch < ApplicationRecord
    self.table_name = 'bulk_import_export_batches'

    BATCH_SIZE = 1000

    belongs_to :export, class_name: 'BulkImports::Export'
    has_one :upload, class_name: 'BulkImports::ExportUpload', foreign_key: :batch_id, inverse_of: :batch

    validates :batch_number, presence: true, uniqueness: { scope: :export_id }

    state_machine :status, initial: :started do
      state :started, value: 0
      state :finished, value: 1
      state :failed, value: -1

      event :start do
        transition any => :started
      end

      event :finish do
        transition started: :finished
        transition failed: :failed
      end

      event :fail_op do
        transition any => :failed
      end
    end
  end
end