sharedlists/db/migrate/20170901200146_add_salt_to_suppliers.rb

20 lines
409 B
Ruby
Raw Normal View History

class AddSaltToSuppliers < ActiveRecord::Migration[4.2]
2021-12-18 11:39:41 +01:00
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
2021-12-18 15:05:53 +01:00
supplier.update! salt: salt
2021-12-18 11:39:41 +01:00
end
change_column_null :suppliers, :salt, false
end
def down
remove_column :suppliers, :salt
end
end