Don't use auto_now_add; you can't override that

This commit is contained in:
Klaas van Schelven
2024-01-05 20:37:05 +01:00
parent fed7d572f7
commit 030f64d874
3 changed files with 20 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('ingest', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='decompressedevent',
name='timestamp',
field=models.DateTimeField(default=django.utils.timezone.now, help_text='Server-side timestamp'),
),
]

View File

@@ -1,6 +1,7 @@
import uuid
from django.db import models
from django.utils import timezone
from projects.models import Project
@@ -10,4 +11,4 @@ class DecompressedEvent(models.Model): # or... DecompressedRawEvent
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
project = models.ForeignKey(Project, blank=False, null=True, on_delete=models.SET_NULL) # SET_NULL: cleanup 'later'
data = models.TextField(blank=False, null=False)
timestamp = models.DateTimeField(null=False, auto_now_add=True, help_text="Server-side timestamp")
timestamp = models.DateTimeField(null=False, default=timezone.now, help_text="Server-side timestamp")

View File

@@ -67,7 +67,7 @@ class BaseIngestAPIView(APIView):
DecompressedEvent.objects.create(
project=project,
data=json.dumps(event_data), # TODO don't parse-then-print for BaseIngestion
timestamp=now, # TODO this doesn't work because of auto_add_now
timestamp=now,
)
debug_info = request.META.get("HTTP_X_BUGSINK_DEBUGINFO", "")