Skip to content
Snippets Groups Projects
Commit f1c5981f authored by Mahyar Damavand's avatar Mahyar Damavand Committed by Julia Eskew
Browse files

Removing deprecated management commands which intended to clear historical data (#21522)

parent 24115bc6
No related branches found
No related tags found
No related merge requests found
"""
Command to delete all rows from the student_historicalcourseenrollment table.
"""
import logging
from openedx.core.djangoapps.util.row_delete import BaseDeletionCommand, delete_rows
from student.models import CourseEnrollment
log = logging.getLogger(__name__)
class Command(BaseDeletionCommand):
"""
Example usage: ./manage.py lms --settings=devstack delete_historical_enrollment_data
"""
help = 'Deletes all historical CourseEnrollment 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(
CourseEnrollment.objects,
'student_historicalcourseenrollment',
'history_id',
chunk_size, sleep_between
)
"""
Command to delete all rows from the verify_student_historicalverificationdeadline table.
"""
import logging
from lms.djangoapps.verify_student.models import VerificationDeadline
from openedx.core.djangoapps.util.row_delete import BaseDeletionCommand, delete_rows
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
)
"""
Command to delete all rows from the api_admin_historicalapiaccessrequest table.
"""
import logging
from openedx.core.djangoapps.api_admin.models import ApiAccessRequest
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_api_admin_data
"""
help = 'Deletes all historical ApiAccessRequest 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(
ApiAccessRequest.objects,
'api_admin_historicalapiaccessrequest',
'history_id',
chunk_size, sleep_between
)
"""
Command to delete all rows from the credit_historicalcreditrequest and
credit_historicalcreditrequirementstatus tables.
"""
import logging
from openedx.core.djangoapps.credit.models import CreditRequest, CreditRequirementStatus
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_credit_data
"""
help = 'Deletes all historical CreditRequest and CreditRequirementStatus 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(
CreditRequest.objects,
'credit_historicalcreditrequest',
'history_id',
chunk_size, sleep_between
)
delete_rows(
CreditRequirementStatus.objects,
'credit_historicalcreditrequirementstatus',
'history_id',
chunk_size, sleep_between
)
"""
Code to delete rows from a table within a Django mgmt command using best practices.
Following lines show how to use delete_rows():
# Command to delete all rows from the student_historicalcourseenrollment table.
import logging
from openedx.core.djangoapps.util.row_delete import BaseDeletionCommand, delete_rows
from student.models import CourseEnrollment
log = logging.getLogger(__name__)
class Command(BaseDeletionCommand):
# Example usage: ./manage.py lms --settings=devstack delete_historical_enrollment_data
help = 'Deletes all historical CourseEnrollment 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(
CourseEnrollment.objects,
'student_historicalcourseenrollment',
'history_id',
chunk_size, sleep_between
)
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment