db/migrate/20150703125325_encrypt_variables.rb (9 lines of code) (raw):

class EncryptVariables < ActiveRecord::Migration def up Variable.find_each do |variable| variable.update(value: variable.read_attribute(:value)) unless variable.encrypted_value end end def down end end