rosa-build/db/migrate/20111011182847_add_extra_fi...

14 lines
381 B
Ruby

class AddExtraFieldsToUsers < ActiveRecord::Migration
def self.up
add_column :users, :nickname, :string
add_column :users, :ssh_key, :text
add_index :users, :nickname, :unique => true
User.all.each {|u| u.update_attribute :nickname, u.email.split('@').first}
end
def self.down
remove_column :users, :ssh_key
remove_column :users, :nickname
end
end