From 021bdd4db69ec32131deafcc0172a9aa9b3a2b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Vantomme?= Date: Fri, 11 Mar 2022 17:02:25 +0100 Subject: [PATCH] fix(after_party): use find_or_create_by to respect idempotency instead of create! --- .../20200630154829_add_traitements_from_dossiers.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/deployment/20200630154829_add_traitements_from_dossiers.rake b/lib/tasks/deployment/20200630154829_add_traitements_from_dossiers.rake index 9940c9843..37f8da244 100644 --- a/lib/tasks/deployment/20200630154829_add_traitements_from_dossiers.rake +++ b/lib/tasks/deployment/20200630154829_add_traitements_from_dossiers.rake @@ -6,7 +6,7 @@ namespace :after_party do dossiers_termines = Dossier.state_termine progress = ProgressReport.new(dossiers_termines.count) dossiers_termines.find_each do |dossier| - dossier.traitements.create!(state: dossier.state, motivation: dossier.motivation, processed_at: dossier.processed_at) + dossier.traitements.find_or_create_by!(state: dossier.state, motivation: dossier.motivation, processed_at: dossier.processed_at) progress.inc end progress.finish