Skip to content
Snippets Groups Projects
Commit 5ca17723 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Init username migration and rake task for create appropriate namespace

parent 26622f4c
No related branches found
No related tags found
No related merge requests found
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment