fix(delete_orphaned_champs_with_missing_dossier): must reload champ before destroying when plucked. also rescue error when repetition chidren is destroyed after parent

This commit is contained in:
mfo 2024-08-30 11:39:50 +02:00
parent ad6aa84774
commit 818e16b234
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC

View file

@ -6,8 +6,14 @@ namespace :after_party do
puts "Running deploy task 'delete_orphaned_champs_with_missing_dossier'"
Champ.select(:id, :type).where.missing(:dossier).each do |champ|
begin
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
# Update task as completed. If you remove the line below, the task will