I have a system made in Ruby on Rails that uses Lockbox in some columns. I need to remove the encrypt from them and generate another one with the data unencrypted. I can't lose the data.
I have very little knowledge of Ruby.
PS: Sorry for the bad english.
CodePudding user response:
Here is an example of how you could copy an encrypted column to a decrypted column (email column on a User model).
Add a migration to add a decrypted column
add_column :users, :decrypted_email, :string
Then write a rake task to fill in the decrypted column for each user
namespace :users do
task :decrypt, [] => [:environment] do |t, args|
User.find_each do |user|
user.update_columns(decrypted_email: user.email)
end
end
end