Skip to content

Commit

Permalink
fixed issue with is_other -> Org upgrade task (DMPRoadmap#2613)
Browse files Browse the repository at this point in the history
  • Loading branch information
briri authored Jul 14, 2020
1 parent 8c38933 commit 4a3bb8b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/tasks/upgrade.rake
Original file line number Diff line number Diff line change
Expand Up @@ -988,12 +988,15 @@ namespace :upgrade do
desc "Attempts to migrate other_organisation entries to Orgs"
task migrate_other_organisation_to_org: :environment do
is_other = Org.find_by(is_other: true)
p "No is_other Org defined, so no orgs need to be created!" unless is_other.present?
return false unless is_other.present?
users = is_other.present? ? User.where(org: is_other) : []

if is_other.present?
p "Processing #{users.length} users attached to '#{is_other.name}' #{is_other.id}"
p "this may take more than 15 minutes depending on how many users are in your database"
else
p "No is_other Org defined, so no orgs need to be created!"
end

users = User.where(org: is_other)
p "Processing #{users.length} users attached to '#{is_other.name}' #{is_other.id}"
p "this may take more than 15 minutes depending on how many users are in your database"
# Unfortunately can't use the Parallel gem here because we can have collisions
# when creating Orgs
users.each do |user|
Expand Down

0 comments on commit 4a3bb8b

Please sign in to comment.