From 33dcd7a7877780d3d816def2bb0c81f2a5e47b05 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Mon, 21 Nov 2022 17:51:33 +0100 Subject: [PATCH] fix(procedure): backfill duree_conservation --- ...20221121163201_clean_invalid_procedures.rake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/tasks/deployment/20221121163201_clean_invalid_procedures.rake diff --git a/lib/tasks/deployment/20221121163201_clean_invalid_procedures.rake b/lib/tasks/deployment/20221121163201_clean_invalid_procedures.rake new file mode 100644 index 000000000..4b5ed6866 --- /dev/null +++ b/lib/tasks/deployment/20221121163201_clean_invalid_procedures.rake @@ -0,0 +1,17 @@ +namespace :after_party do + desc 'Deployment task: clean_invalid_procedures' + task clean_invalid_procedures: :environment do + puts "Running deploy task 'clean_invalid_procedures'" + + Procedure.with_discarded.where(duree_conservation_etendue_par_ds: nil) + .update_all(duree_conservation_etendue_par_ds: false) + + Procedure.with_discarded.where(max_duree_conservation_dossiers_dans_ds: nil) + .update_all(max_duree_conservation_dossiers_dans_ds: Procedure::NEW_MAX_DUREE_CONSERVATION) + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord + .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp + end +end