Finally add Map.create_at field

This field should have been added at the beginning, but this is
like planting trees, isn't it ?
This commit is contained in:
Yohan Boniface 2023-09-27 11:01:50 +02:00
parent 4e3a22dc11
commit 495dd6444f
2 changed files with 24 additions and 0 deletions

View file

@ -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;"),
]

View file

@ -163,6 +163,7 @@ class Map(NamedModel):
on_delete=models.SET_DEFAULT, on_delete=models.SET_DEFAULT,
default=get_default_licence, default=get_default_licence,
) )
created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True) modified_at = models.DateTimeField(auto_now=True)
owner = models.ForeignKey( owner = models.ForeignKey(
settings.AUTH_USER_MODEL, settings.AUTH_USER_MODEL,