Commit 5ca17723 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Init username migration and rake task for create appropriate namespace

parent 26622f4c
class AddUsernameToUser < ActiveRecord::Migration
def change
add_column :users, :username, :string, null: true
end
end
namespace :gitlab do
desc "GITLAB | Enable usernames and namespaces for user projects"
task activate_namespaces: :environment do
User.find_each(batch_size: 500) do |user|
User.transaction do
username = user.email.match(/^[^@]*/)[0]
user.update_attributes!(username: username)
user.create_namespace!(code: username, name: user.name)
print '.'.green
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment