Fixed migration erroring (#1681)

This commit is contained in:
Ahmad Farhat 2020-05-27 17:45:35 -04:00 committed by GitHub
parent db6db06a78
commit b0de03cc09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -16,7 +16,7 @@ class AddRoleIdToUsers < ActiveRecord::Migration[5.2]
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