2021-12-18 23:52:05 +01:00
|
|
|
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
|