Merge pull request #10726 from mfo/fix-delete-orphaned

correctif : ETQ tech je souhaite que a tache qui détruit les champs sans dossier fonctionne
This commit is contained in:
LeSim 2024-08-30 12:00:36 +00:00 committed by GitHub
commit 7693d216d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,8 +6,14 @@ namespace :after_party do
puts "Running deploy task 'delete_orphaned_champs_with_missing_dossier'" puts "Running deploy task 'delete_orphaned_champs_with_missing_dossier'"
Champ.select(:id, :type).where.missing(:dossier).each do |champ| Champ.select(:id, :type).where.missing(:dossier).each do |champ|
champ.champs.destroy_all if champ.type == 'Champs::RepetitionChamp' begin
champ.destroy champ.reload
champ.champs.destroy_all if champ.type == 'Champs::RepetitionChamp'
champ.destroy
rake_puts "succeed with: #{champ.id}"
rescue ActiveRecord::RecordNotFound
rake_puts "failed with: #{champ.id}"
end
end end
# Update task as completed. If you remove the line below, the task will # Update task as completed. If you remove the line below, the task will