From bf3d142c1522d0f43993e68745027640982e3a67 Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Thu, 8 Jul 2021 13:03:58 +0200 Subject: [PATCH] For future use, also store who created each query and when (#486) --- .../migrations/0005_auto_20210708_1249.py | 28 +++++++++++++++++++ backend/items/models.py | 5 ++++ 2 files changed, 33 insertions(+) create mode 100644 backend/items/migrations/0005_auto_20210708_1249.py diff --git a/backend/items/migrations/0005_auto_20210708_1249.py b/backend/items/migrations/0005_auto_20210708_1249.py new file mode 100644 index 00000000..83eb1d67 --- /dev/null +++ b/backend/items/migrations/0005_auto_20210708_1249.py @@ -0,0 +1,28 @@ +# Generated by Django 2.0.13 on 2021-07-08 10:49 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('items', '0004_semanticquery'), + ] + + operations = [ + migrations.AddField( + model_name='semanticquery', + name='created', + field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), + preserve_default=False, + ), + migrations.AddField( + model_name='semanticquery', + name='creator', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/backend/items/models.py b/backend/items/models.py index be0eac68..d3fe2755 100644 --- a/backend/items/models.py +++ b/backend/items/models.py @@ -1,5 +1,6 @@ from django.db import models from django.contrib.postgres.fields import JSONField +from django.conf import settings from rdf.baseclasses import BaseCounter from .constants import ITEMS_NS, ITEMS_HISTORY_NS @@ -16,6 +17,10 @@ class EditCounter(BaseCounter): class SemanticQuery(models.Model): label = models.CharField(blank=True, max_length=100) query = JSONField() + creator = models.ForeignKey( + settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL, + ) + created = models.DateTimeField(auto_now_add=True) def __str__(self): return self.label or str(self.id)