diff --git a/lib/tasks/support.rake b/lib/tasks/support.rake index e4832dd67..d889ecb17 100644 --- a/lib/tasks/support.rake +++ b/lib/tasks/support.rake @@ -48,4 +48,26 @@ namespace :support do user.dossiers.each(&:delete_and_keep_track) user.destroy end + + desc <<~EOD + Change the SIRET for a given dossier (specified by DOSSIER_ID) + EOD + task update_dossier_siret: :environment do + siret_number = ENV['SIRET'] + dossier_id = ENV['DOSSIER_ID'] + + if siret_number.nil? + fail "Must specify a SIRET" + end + + siret_number = siret_number.dup # Unfreeze the string + siret = Siret.new(siret: siret_number) + if siret.invalid? + fail siret.errors.full_messages.to_sentence + end + + dossier = Dossier.find(dossier_id) + + EtablissementUpdateJob.perform_now(dossier, siret_number) + end end