Mgmt commands to clear data from historical tables.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
Command to delete all rows from these tables:
|
||||
microsite_configuration_historicalmicrositeorganizationmapping
|
||||
microsite_configuration_historicalmicrositetemplate
|
||||
"""
|
||||
|
||||
import logging
|
||||
from common.djangoapps.microsite_configuration.models import MicrositeOrganizationMapping, MicrositeTemplate
|
||||
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_microsite_data
|
||||
"""
|
||||
help = 'Deletes all historical MicrositeOrganizationMapping and MicrositeTemplate 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(
|
||||
MicrositeOrganizationMapping.objects,
|
||||
'microsite_configuration_historicalmicrositeorganizationmapping',
|
||||
'history_id',
|
||||
chunk_size, sleep_between
|
||||
)
|
||||
delete_rows(
|
||||
MicrositeTemplate.objects,
|
||||
'microsite_configuration_historicalmicrositetemplate',
|
||||
'history_id',
|
||||
chunk_size, sleep_between
|
||||
)
|
||||
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
Command to delete all rows from the student_historicalcourseenrollment table.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from student.models import CourseEnrollment
|
||||
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_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
|
||||
)
|
||||
Reference in New Issue
Block a user