paperless-ngx/src/documents/migrations/0020_document_added.py

29 lines
749 B
Python
Raw Normal View History

from django.db import migrations, models
import django.utils.timezone
def set_added_time_to_created_time(apps, schema_editor):
Document = apps.get_model("documents", "Document")
for doc in Document.objects.all():
doc.added = doc.created
doc.save()
2018-09-02 21:26:20 +01:00
class Migration(migrations.Migration):
dependencies = [
2022-02-27 15:26:41 +01:00
("documents", "0019_add_consumer_user"),
]
operations = [
migrations.AddField(
2022-02-27 15:26:41 +01:00
model_name="document",
name="added",
field=models.DateTimeField(
db_index=True,
default=django.utils.timezone.now,
editable=False,
2022-02-27 15:26:41 +01:00
),
),
2022-02-27 15:26:41 +01:00
migrations.RunPython(set_added_time_to_created_time),
]