Skip to content

Commit

Permalink
Safeguard rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
jahseng-lee committed Mar 31, 2024
1 parent 89f0b96 commit a23b166
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/tasks/countries.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ namespace :countries do
next if country.locations.empty?

if Rails.env.production?
# Skip if one already exists
next if VisaInformation.find_by(
country_id: country.id,
citizenship_id: nil
).present?

VisaInformation.create!(
country_id: country.id,
citizenship_id: nil,
Expand Down Expand Up @@ -86,6 +92,11 @@ namespace :countries do
# This is a manually created list of "citzenship" countries
# which will be initially excluded
next if NON_SEED_CITIZENSHIPS.include?(citizenship.name)
# Skip if one already exists
next if VisaInformation.find_by(
country_id: country.id,
citizenship_id: citizenship.id
).present?

if country.id == citizenship.id
VisaInformation.create!(
Expand Down

0 comments on commit a23b166

Please sign in to comment.