Unverified Commit b0de03cc authored by Ahmad Farhat's avatar Ahmad Farhat Committed by GitHub
Browse files

Fixed migration erroring (#1681)

parent db6db06a
...@@ -16,7 +16,7 @@ class AddRoleIdToUsers < ActiveRecord::Migration[5.2] ...@@ -16,7 +16,7 @@ class AddRoleIdToUsers < ActiveRecord::Migration[5.2]
MigrationProduct.where(role_id: nil).each do |user| MigrationProduct.where(role_id: nil).each do |user|
highest_role = SubMigrationProduct.joins("INNER JOIN users_roles ON users_roles.role_id = roles.id") 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? user.update_attributes(role_id: highest_role) unless highest_role.nil?
end end
end end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment