2011-10-11 21:56:51 +01:00
|
|
|
class AddExtraFieldsToUsers < ActiveRecord::Migration
|
|
|
|
def self.up
|
|
|
|
add_column :users, :nickname, :string
|
|
|
|
add_column :users, :ssh_key, :text
|
|
|
|
add_index :users, :nickname, :unique => true
|
2011-10-17 11:29:07 +01:00
|
|
|
User.all.each {|u| User.where(:id => u.id).update_all(:nickname => u.email.split('@').first)}
|
2011-10-11 21:56:51 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
|
|
|
remove_column :users, :ssh_key
|
|
|
|
remove_column :users, :nickname
|
|
|
|
end
|
|
|
|
end
|