Skip to content

Commit

Permalink
make hard deletion actions atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
mjriley committed Dec 12, 2024
1 parent 0537ba7 commit 620c669
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions corehq/form_processor/models/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,10 @@ def hard_delete_forms(
for db_name, split_form_ids in split_list_by_db_partition(form_ids):
# cascade should delete the operations
query = self.using(db_name).filter(domain=domain, form_id__in=split_form_ids)
if return_ids:
found_forms = list(query.values_list('form_id', flat=True))
_, deleted_models = query.delete()
with transaction.atomic():
if return_ids:
found_forms = list(query.values_list('form_id', flat=True))
_, deleted_models = query.delete()
deleted_count += deleted_models.get(self.model._meta.label, 0)
if return_ids:
deleted_ids.extend(found_forms)
Expand Down

0 comments on commit 620c669

Please sign in to comment.