# Generated by Django 3.2.15 on 2022-12-16 14:39
import django.utils.timezone
from django.db import migrations
from django.db import models

from buildinfo.utils import get_datetime


def migrate_timestamps(apps, schema_editor):
    BuildInfo = apps.get_model("buildinfo", "BuildInfo")
    for info in BuildInfo.objects.all():
        info.datetime = get_datetime(info.timestamp)
        info.save()


class Migration(migrations.Migration):

    dependencies = [
        ("buildinfo", "0003_duration_fix"),
    ]

    operations = [
        migrations.AddField(
            model_name="buildinfo",
            name="datetime",
            field=models.DateTimeField(default=django.utils.timezone.now),
            preserve_default=False,
        ),
        migrations.RunPython(migrate_timestamps),
        migrations.RemoveField(model_name="buildinfo", name="timestamp"),
    ]
