class ActiveRecord::Migration

Public Instance Methods

unencrypt_field(model, column, key:) click to toggle source
# File lib/encryption_migrator.rb, line 27
def unencrypt_field(model, column, key:)
  const = EncryptionMigrator.constant_for(model)
  encrypted_sym = :"encrypted_#{column}"

  add_column model, column, :string
  const.reset_column_information

  const.all.each do |row|
    EncryptionMigrator.decrypt_and_update_row(row, const, column, key)
  end

  remove_column model, encrypted_sym
end