From 0c184e9b1df68865bf754d51a1b8b2711c37e48e Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sun, 25 Apr 2021 20:24:32 +0000 Subject: [PATCH] Remove history for UsageTrack --- apiserver/apiserver/api/models.py | 2 -- apiserver/delete_usagetracks.py | 13 +++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100755 apiserver/delete_usagetracks.py diff --git a/apiserver/apiserver/api/models.py b/apiserver/apiserver/api/models.py index 0a9517b..021821d 100644 --- a/apiserver/apiserver/api/models.py +++ b/apiserver/apiserver/api/models.py @@ -165,8 +165,6 @@ class UsageTrack(models.Model): start_time = models.DateTimeField(auto_now_add=True) num_seconds = models.IntegerField() - history = HistoricalRecords(excluded_fields=['num_seconds']) - class HistoryIndex(models.Model): content_type = models.ForeignKey(ContentType, null=True, on_delete=models.SET_NULL) object_id = models.PositiveIntegerField() diff --git a/apiserver/delete_usagetracks.py b/apiserver/delete_usagetracks.py new file mode 100755 index 0000000..c45e8c0 --- /dev/null +++ b/apiserver/delete_usagetracks.py @@ -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')