Skip to content
Snippets Groups Projects
Unverified Commit 8010adfa authored by David Fernandez's avatar David Fernandez
Browse files

Apply database reviewer feedback

Use `#queue_background_migration_jobs_by_range_at_intervals`
parent d580a39e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -10,19 +10,15 @@ class ScheduleDisableExpirationPoliciesLinkedToNoContainerImages < ActiveRecord:
 
disable_ddl_transaction!
 
class ContainerExpirationPolicy < ActiveRecord::Base
include ::EachBatch
self.table_name = 'container_expiration_policies'
end
def up
ContainerExpirationPolicy.where(enabled: true).each_batch(of: BATCH_SIZE) do |batch, index|
range = batch.pluck(Arel.sql('MIN(project_id)'), Arel.sql('MAX(project_id)')).first
delay = index * DELAY
migrate_in(delay.seconds, MIGRATION, range)
end
queue_background_migration_jobs_by_range_at_intervals(
define_batchable_model('container_expiration_policies').where(enabled: true),
MIGRATION,
DELAY,
batch_size: BATCH_SIZE,
track_jobs: true,
primary_column_name: :project_id
)
end
 
def down
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment