sharedlists/db/migrate/20170901200146_add_salt_to_suppliers.rb
2021-12-18 15:05:53 +01:00

19 lines
404 B
Ruby

class AddSaltToSuppliers < ActiveRecord::Migration
class Supplier < ActiveRecord::Base; end
def up
add_column :suppliers, :salt, :string
Supplier.find_each do |supplier|
salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp
supplier.update! salt: salt
end
change_column_null :suppliers, :salt, false
end
def down
remove_column :suppliers, :salt
end
end