summaryrefslogtreecommitdiff
path: root/db/post_migrate/20210514063252_schedule_cleanup_orphaned_lfs_objects_projects.rb
blob: 76e4a0a95bb50f6c3488f5426e857dcb0f865ec9 (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
# frozen_string_literal: true

class ScheduleCleanupOrphanedLfsObjectsProjects < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  MIGRATION = 'CleanupOrphanedLfsObjectsProjects'
  DELAY_INTERVAL = 2.minutes
  BATCH_SIZE = 50_000

  disable_ddl_transaction!

  class LfsObjectsProject < ActiveRecord::Base
    self.table_name = 'lfs_objects_projects'

    include ::EachBatch
  end

  def up
    queue_background_migration_jobs_by_range_at_intervals(LfsObjectsProject, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE)
  end

  def down
    # NOOP
  end
end