debian-mirror-gitlab/lib/gitlab/background_migration/migrate_u2f_webauthn.rb

29 lines
837 B
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
# rubocop:disable Style/Documentation
module Gitlab
module BackgroundMigration
class MigrateU2fWebauthn
class U2fRegistration < ActiveRecord::Base
self.table_name = 'u2f_registrations'
end
class WebauthnRegistration < ActiveRecord::Base
self.table_name = 'webauthn_registrations'
end
def perform(start_id, end_id)
old_registrations = U2fRegistration.where(id: start_id..end_id)
old_registrations.each_slice(100) do |slice|
values = slice.map do |u2f_registration|
2021-03-11 19:13:27 +05:30
converter = Gitlab::Auth::U2fWebauthnConverter.new(u2f_registration)
converter.convert
2021-01-03 14:25:43 +05:30
end
WebauthnRegistration.insert_all(values, unique_by: :credential_xid, returning: false)
end
end
end
end
end