# -*- coding: utf-8 -*- from __future__ import unicode_literals 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() class Migration(migrations.Migration): dependencies = [ ("documents", "0019_add_consumer_user"), ] operations = [ migrations.AddField( model_name="document", name="added", field=models.DateTimeField( db_index=True, default=django.utils.timezone.now, editable=False ), ), migrations.RunPython(set_added_time_to_created_time), ]