From e2e3f9fdce386f221554d1b92ed3c79e26c5a353 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Mon, 18 Sep 2023 16:44:05 +0200 Subject: [PATCH] fix: destroy Individual of dossier for etablissements --- ...918143300_fix_prefilled_empty_individual.rake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/tasks/deployment/20230918143300_fix_prefilled_empty_individual.rake diff --git a/lib/tasks/deployment/20230918143300_fix_prefilled_empty_individual.rake b/lib/tasks/deployment/20230918143300_fix_prefilled_empty_individual.rake new file mode 100644 index 000000000..68f570f95 --- /dev/null +++ b/lib/tasks/deployment/20230918143300_fix_prefilled_empty_individual.rake @@ -0,0 +1,16 @@ +namespace :after_party do + desc 'Deployment task: fix_prefilled_empty_individual' + task fix_prefilled_empty_individual: :environment do + puts "Running deploy task 'fix_prefilled_empty_individual'" + + Dossier.prefilled.joins(:procedure).joins(:individual).where(procedure: { for_individual: false }).find_each do |dossier| + rake_puts "Destroy Individual of dossier ##{dossier.id}" + dossier.individual.destroy! + end + + # 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