From 2edf8978ca1fee22441fab72307d90ec067f1ee1 Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Wed, 27 May 2020 17:45:35 -0400 Subject: [PATCH] Fixed migration erroring (#1681) --- db/migrate/20200413150518_add_role_id_to_users.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20200413150518_add_role_id_to_users.rb b/db/migrate/20200413150518_add_role_id_to_users.rb index 18b0863cea7..45b018cea19 100644 --- a/db/migrate/20200413150518_add_role_id_to_users.rb +++ b/db/migrate/20200413150518_add_role_id_to_users.rb @@ -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