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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/database/background_migration/batched_migration.rb')
-rw-r--r--lib/gitlab/database/background_migration/batched_migration.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/gitlab/database/background_migration/batched_migration.rb b/lib/gitlab/database/background_migration/batched_migration.rb
index e85162f355e..36e89023c86 100644
--- a/lib/gitlab/database/background_migration/batched_migration.rb
+++ b/lib/gitlab/database/background_migration/batched_migration.rb
@@ -14,12 +14,20 @@ module Gitlab
class_name: 'Gitlab::Database::BackgroundMigration::BatchedJob',
foreign_key: :batched_background_migration_id
+ validates :job_arguments, uniqueness: {
+ scope: [:job_class_name, :table_name, :column_name]
+ }
+
scope :queue_order, -> { order(id: :asc) }
+ scope :queued, -> { where(status: [:active, :paused]) }
+ scope :for_configuration, ->(job_class_name, table_name, column_name, job_arguments) do
+ where(job_class_name: job_class_name, table_name: table_name, column_name: column_name)
+ .where("job_arguments = ?", job_arguments.to_json) # rubocop:disable Rails/WhereEquals
+ end
enum status: {
paused: 0,
active: 1,
- aborted: 2,
finished: 3,
failed: 4
}
@@ -30,6 +38,14 @@ module Gitlab
active.queue_order.first
end
+ def self.successful_rows_counts(migrations)
+ BatchedJob
+ .succeeded
+ .where(batched_background_migration_id: migrations)
+ .group(:batched_background_migration_id)
+ .sum(:batch_size)
+ end
+
def interval_elapsed?(variance: 0)
return true unless last_job