initial import boxroom 0.6.2
[boxroom-stian.git] / db / migrate / 002_add_password_salt_to_user.rb
blobf0b50c0af5a95ee1d436fd7dcd381c0a2f4a10ca
1 class AddPasswordSaltToUser < ActiveRecord::Migration
2   def self.up
3     # Add password_salt column to the users table.
4     add_column :users, 'password_salt', :string
5     add_index :users, :password_salt
7     # Set the salt for current users to empty.
8     # This way passwords stay valid.
9     for u in User.find(:all)
10       u.password_salt = ''
11       u.save
12     end
13   end
15   def self.down
16     remove_index :users, :password_salt
17     remove_column :users, 'password_salt'
18   end
19 end