class OnlineMigrations::BackgroundMigrations::MigrationJob

Constants

STATUSES

Public Instance Methods

retry() click to toggle source

Mark this job as ready to be processed again.

This is used when retrying failed jobs.

# File lib/online_migrations/background_migrations/migration_job.rb, line 62
def retry
  update!(
    status: self.class.statuses[:enqueued],
    attempts: 0,
    started_at: nil,
    finished_at: nil
  )
end

Private Instance Methods

copy_settings_from_migration() click to toggle source
# File lib/online_migrations/background_migrations/migration_job.rb, line 84
def copy_settings_from_migration
  self.batch_size       = migration.batch_size
  self.sub_batch_size   = migration.sub_batch_size
  self.pause_ms         = migration.sub_batch_pause_ms
  self.max_attempts     = migration.batch_max_attempts
end
validate_values_order() click to toggle source
# File lib/online_migrations/background_migrations/migration_job.rb, line 78
def validate_values_order
  if max_value.to_i < min_value.to_i
    errors.add(:base, "max_value should be greater than or equal to min_value")
  end
end
values_in_migration_range() click to toggle source
# File lib/online_migrations/background_migrations/migration_job.rb, line 72
def values_in_migration_range
  if min_value < migration.min_value || max_value > migration.max_value
    errors.add(:base, "min_value and max_value should be in background migration values range")
  end
end