summaryrefslogtreecommitdiff
path: root/db/post_migrate/20200310075115_schedule_link_lfs_objects_projects.rb
blob: d1ed53d8e70b42f323f6f57e5fc3505c9d6d7073 (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
# frozen_string_literal: true

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

  DOWNTIME = false
  MIGRATION = 'LinkLfsObjectsProjects'
  BATCH_SIZE = 1000

  disable_ddl_transaction!

  def up
    lfs_objects_projects = Gitlab::BackgroundMigration::LinkLfsObjectsProjects::LfsObjectsProject.linkable

    queue_background_migration_jobs_by_range_at_intervals(
      lfs_objects_projects,
      MIGRATION,
      BackgroundMigrationWorker.minimum_interval,
      batch_size: BATCH_SIZE
    )
  end

  def down
    # No-op. No need to make this reversible. In case the jobs enqueued runs and
    # fails at some point, some records will be created. When rescheduled, those
    # records won't be re-created. It's also hard to track which records to clean
    # up if ever.
  end
end