From e5ae9f173931b073ea2a37c9f59770fae8f210c2 Mon Sep 17 00:00:00 2001 From: Chris Pappas Date: Mon, 20 Nov 2023 13:20:39 -0500 Subject: [PATCH] temp: add management command to delete all test records (#25) * temp: add management command to delete all test records --- .../commands/delete_all_metadata_records.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sanctions/apps/sanctions/management/commands/delete_all_metadata_records.py diff --git a/sanctions/apps/sanctions/management/commands/delete_all_metadata_records.py b/sanctions/apps/sanctions/management/commands/delete_all_metadata_records.py new file mode 100644 index 0000000..03f251a --- /dev/null +++ b/sanctions/apps/sanctions/management/commands/delete_all_metadata_records.py @@ -0,0 +1,28 @@ +""" +Django management command to delete all metadata records. +""" +import logging + +from django.core.management.base import BaseCommand + +from sanctions.apps.sanctions.models import SanctionsCheckFailure + +logger = logging.getLogger(__name__) + + +class Command(BaseCommand): + """ + Command to delete all SanctionsCheckFailure records. + """ + help = 'Delete all SanctionsCheckFailure records.' + + def handle(self, *args, **options): + logger.info('Beginning deletion of SanctionsCheckFailure records.') + all_records = SanctionsCheckFailure.objects.all().iterator() + + for record in all_records: + logger.info('Deleting record %s', record.id) + record.delete() + logger.info('Deleted record %s', record.id) + + logger.info('Completed deletion of SanctionsCheckFailure records.')