summaryrefslogtreecommitdiff
path: root/db/post_migrate/20200929114107_schedule_migrate_u2f_webauthn.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20200929114107_schedule_migrate_u2f_webauthn.rb')
-rw-r--r--db/post_migrate/20200929114107_schedule_migrate_u2f_webauthn.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/db/post_migrate/20200929114107_schedule_migrate_u2f_webauthn.rb b/db/post_migrate/20200929114107_schedule_migrate_u2f_webauthn.rb
new file mode 100644
index 00000000000..b118ed271a2
--- /dev/null
+++ b/db/post_migrate/20200929114107_schedule_migrate_u2f_webauthn.rb
@@ -0,0 +1,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