Mgmt commands to clear data from historical tables.

This commit is contained in:
John Eskew
2017-10-12 16:15:09 -04:00
parent 5557eae276
commit f3e089bd3f
12 changed files with 253 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
"""
Command to delete all rows from the verify_student_historicalverificationdeadline table.
"""
import logging
from verify_student.models import VerificationDeadline
from openedx.core.djangoapps.util.row_delete import delete_rows, BaseDeletionCommand
log = logging.getLogger(__name__)
class Command(BaseDeletionCommand):
"""
Example usage: ./manage.py lms --settings=devstack delete_historical_verify_student_data
"""
help = 'Deletes all historical VerificationDeadline rows (in chunks).'
def handle(self, *args, **options):
"""
Deletes rows, chunking the deletes to avoid long table/row locks.
"""
chunk_size, sleep_between = super(Command, self).handle(*args, **options)
delete_rows(
VerificationDeadline.objects,
'verify_student_historicalverificationdeadline',
'history_id',
chunk_size, sleep_between
)