Data migration task

This commit is contained in:
Matt Jankowski 2024-02-12 08:59:02 -05:00
parent 95c891c1f2
commit 231817581c
1 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
namespace :devise_two_factor do
desc 'Copy devise_two_factor OTP secret from old format to new format'
task migrate_encryption_format: [:environment] do
# Find user records 1_000 at a time
User.find_each do |user|
# Get the new value on already-updated users, or fall back to legacy value on not yet migrated
otp_secret = user.otp_secret
puts "Processing #{user.email}"
# This is a no-op for migrated, and will update format for not migrated
user.update!(otp_secret: otp_secret)
end
end
end