Commit 48fbce53f7ac7cf65f1b68321fde815f9cd280d6
1 parent
d00567a9
Exists in
staging
and in
4 other branches
oauth_client: fix migration
Showing
1 changed file
with
5 additions
and
2 deletions
Show diff stats
plugins/oauth_client/db/migrate/20150815173209_add_authorization_data_to_oauth_client_user_provider.rb
... | ... | @@ -12,8 +12,11 @@ class AddAuthorizationDataToOauthClientUserProvider < ActiveRecord::Migration |
12 | 12 | |
13 | 13 | add_column :oauth_client_plugin_auths, :profile_id, :integer |
14 | 14 | OauthClientPlugin::Auth.find_each batch_size: 50 do |auth| |
15 | - auth.profile = User.find(auth.user_id).person | |
16 | - auth.save! | |
15 | + user = User.find_by_id(auth.user_id) | |
16 | + if user.present? | |
17 | + auth.profile = user.person | |
18 | + auth.save! | |
19 | + end | |
17 | 20 | end |
18 | 21 | remove_column :oauth_client_plugin_auths, :user_id |
19 | 22 | ... | ... |