Remove history for UsageTrack

This commit is contained in:
Tanner Collin 2021-04-25 20:24:32 +00:00
parent 1ae93791f9
commit 0c184e9b1d
2 changed files with 13 additions and 2 deletions

View File

@ -165,8 +165,6 @@ class UsageTrack(models.Model):
start_time = models.DateTimeField(auto_now_add=True) start_time = models.DateTimeField(auto_now_add=True)
num_seconds = models.IntegerField() num_seconds = models.IntegerField()
history = HistoricalRecords(excluded_fields=['num_seconds'])
class HistoryIndex(models.Model): class HistoryIndex(models.Model):
content_type = models.ForeignKey(ContentType, null=True, on_delete=models.SET_NULL) content_type = models.ForeignKey(ContentType, null=True, on_delete=models.SET_NULL)
object_id = models.PositiveIntegerField() object_id = models.PositiveIntegerField()

13
apiserver/delete_usagetracks.py Executable file
View File

@ -0,0 +1,13 @@
import django, sys, os
os.environ['DJANGO_SETTINGS_MODULE'] = 'apiserver.settings'
django.setup()
from apiserver.api import models
indexs = models.HistoryIndex.objects.filter(object_name='UsageTrack')
count = indexs.delete()
print(count, 'indexs deleted')
changes = models.HistoryChange.objects.filter(field='num_seconds')
count = changes.delete()
print(count, 'changes deleted')