diff --git a/umap/migrations/0014_map_created_at.py b/umap/migrations/0014_map_created_at.py new file mode 100644 index 00000000..5768776c --- /dev/null +++ b/umap/migrations/0014_map_created_at.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.2 on 2023-09-27 08:50 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + dependencies = [ + ("umap", "0013_datalayer_edit_status"), + ] + + operations = [ + migrations.AddField( + model_name="map", + name="created_at", + field=models.DateTimeField( + auto_now_add=True, default=django.utils.timezone.now + ), + preserve_default=False, + ), + # Did not find a way to provide default from a column in the field creation + migrations.RunSQL("UPDATE umap_map SET created_at=modified_at;"), + ] diff --git a/umap/models.py b/umap/models.py index 86c69518..b2d1a9a6 100644 --- a/umap/models.py +++ b/umap/models.py @@ -163,6 +163,7 @@ class Map(NamedModel): on_delete=models.SET_DEFAULT, default=get_default_licence, ) + created_at = models.DateTimeField(auto_now_add=True) modified_at = models.DateTimeField(auto_now=True) owner = models.ForeignKey( settings.AUTH_USER_MODEL,