[ARVADOS] updated: fa2abe9605aa2e10bac2c50985d54fe2d08208da

git at public.curoverse.com git at public.curoverse.com
Wed Mar 25 10:16:56 EDT 2015


Summary of changes:
 services/api/db/migrate/20150317132720_add_username_to_users.rb | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

       via  fa2abe9605aa2e10bac2c50985d54fe2d08208da (commit)
      from  fa92aa4a1db149f2938351ae1220f5d1a08a3b8e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit fa2abe9605aa2e10bac2c50985d54fe2d08208da
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Mar 25 10:16:51 2015 -0400

    4253: Fixup migration by having Rails check for duplicate usernames.

diff --git a/services/api/db/migrate/20150317132720_add_username_to_users.rb b/services/api/db/migrate/20150317132720_add_username_to_users.rb
index 6772414..de2fc96 100644
--- a/services/api/db/migrate/20150317132720_add_username_to_users.rb
+++ b/services/api/db/migrate/20150317132720_add_username_to_users.rb
@@ -107,17 +107,14 @@ class AddUsernameToUsers < ActiveRecord::Migration
     recreate_search_index(SEARCH_INDEX_COLUMNS + ["username"])
 
     [Link, Log, User].each { |m| m.reset_column_information }
+    User.validates(:username, uniqueness: true, allow_nil: true)
     User.where(is_active: true).order(created_at: :asc).find_each do |user|
       start_log = Log.log_for(user)
       each_wanted_username(user) do |username|
         user.username = username
-        begin
-          user.save!
-          break
-        rescue ActiveRecord::RecordNotUnique
-          # We'll try the next username.
-        end
+        break if user.valid?
       end
+      user.save!
       Log.log_update(user, start_log)
     end
   end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list