From 9798e268dfcc12f5a051416e9b3c35a82d68dbf5 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 13 May 2022 15:59:46 +0200 Subject: [PATCH] fix(sentry/3139111475): clean up some "corrupted" data, some dossier still have depose_at nil while en_construction_at is set --- ...e_at_nil_on_dossier_state_not_brouillon.rake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/tasks/deployment/20220513135112_fix_depose_at_nil_on_dossier_state_not_brouillon.rake diff --git a/lib/tasks/deployment/20220513135112_fix_depose_at_nil_on_dossier_state_not_brouillon.rake b/lib/tasks/deployment/20220513135112_fix_depose_at_nil_on_dossier_state_not_brouillon.rake new file mode 100644 index 000000000..d41e6d2fc --- /dev/null +++ b/lib/tasks/deployment/20220513135112_fix_depose_at_nil_on_dossier_state_not_brouillon.rake @@ -0,0 +1,17 @@ +namespace :after_party do + desc 'Deployment task: fix_depose_at_nil_on_dossier_state_not_brouillon' + task fix_depose_at_nil_on_dossier_state_not_brouillon: :environment do + puts "Running deploy task 'fix_depose_at_nil_on_dossier_state_not_brouillon'" + + # Put your task implementation HERE. + dossiers_with_depose_at_nil = Dossier.state_not_brouillon.where(depose_at: nil) + + rake_puts "Number of dossiers not in brouillon without depose_at : #{dossiers_with_depose_at_nil.count}" + + dossiers_with_depose_at_nil.update_all("depose_at = en_construction_at") + # 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