Skip to content

Commit

Permalink
Fixed migration erroring (#1681)
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad authored May 27, 2020
1 parent db6db06 commit b0de03c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion db/migrate/20200413150518_add_role_id_to_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def change

MigrationProduct.where(role_id: nil).each do |user|
highest_role = SubMigrationProduct.joins("INNER JOIN users_roles ON users_roles.role_id = roles.id")
.where("users_roles.user_id = '#{user.id}'").min_by(&:priority).id
.where("users_roles.user_id = '#{user.id}'")&.min_by(&:priority)&.id
user.update_attributes(role_id: highest_role) unless highest_role.nil?
end
end
Expand Down

0 comments on commit b0de03c

Please sign in to comment.