# Generated by Django 5.2.4 on 2025-09-27 23:29

from django.db import migrations, models
from django.db.models import F


def _copy_existing_times(apps, schema_editor):
    Transaction = apps.get_model("ocpp", "Transaction")
    Transaction.objects.filter(received_start_time__isnull=True).update(
        received_start_time=F("start_time")
    )
    Transaction.objects.filter(received_stop_time__isnull=True).update(
        received_stop_time=F("stop_time")
    )


class Migration(migrations.Migration):

    dependencies = [
        ("ocpp", "0023_simulator_configuration_keys_and_more"),
    ]

    operations = [
        migrations.AddField(
            model_name="transaction",
            name="received_start_time",
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="transaction",
            name="received_stop_time",
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.RunPython(_copy_existing_times, migrations.RunPython.noop),
    ]
