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

20200929114107_schedule_migrate_u2f_webauthn.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b118ed271a2b4d791874c9291ae1a5b54b7035c2 (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
30
31
# frozen_string_literal: true

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

  INTERVAL = 2.minutes.to_i
  DOWNTIME = false
  MIGRATION = 'MigrateU2fWebauthn'
  BATCH_SIZE = 1_000

  disable_ddl_transaction!

  class U2fRegistration < ActiveRecord::Base
    include EachBatch

    self.table_name = 'u2f_registrations'
  end

  def up
    say "Scheduling #{MIGRATION} background migration jobs"

    queue_background_migration_jobs_by_range_at_intervals(U2fRegistration, MIGRATION, INTERVAL, batch_size: BATCH_SIZE)
  end

  def down
    # no-op
    # There is no real way back here, because
    # a) The U2fMigrator of webauthn_ruby gem only works in one way
    # b) This migration only pushes jobs to Sidekiq
  end
end