# Generated by Django 5.2.4 on 2025-09-09 15:28

from django.db import migrations, models
import django.utils.timezone
from core.models import validate_relative_url


def add_invitelead_fields(apps, schema_editor):
    InviteLead = apps.get_model("core", "InviteLead")
    table = InviteLead._meta.db_table
    with schema_editor.connection.cursor() as cursor:
        existing = {
            column.name
            for column in schema_editor.connection.introspection.get_table_description(
                cursor, table
            )
        }

    fields = []
    if "error" not in existing:
        field = models.TextField(blank=True)
        field.set_attributes_from_name("error")
        fields.append((InviteLead, field))
    if "sent_on" not in existing:
        field = models.DateTimeField(blank=True, null=True)
        field.set_attributes_from_name("sent_on")
        fields.append((InviteLead, field))

    for model, field in fields:
        schema_editor.add_field(model, field)


def noop(*args, **kwargs):
    pass


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0010_businesspowerlead"),
    ]

    operations = [
        migrations.CreateModel(
            name="Todo",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("description", models.CharField(max_length=255)),
                (
                    "url",
                    models.CharField(
                        blank=True,
                        default="",
                        max_length=200,
                        validators=[validate_relative_url],
                    ),
                ),
            ],
            options={
                "verbose_name": "TODO",
                "verbose_name_plural": "TODOs",
            },
        ),
        migrations.SeparateDatabaseAndState(
            database_operations=[
                migrations.RunPython(add_invitelead_fields, noop),
            ],
            state_operations=[
                migrations.AddField(
                    model_name="invitelead",
                    name="error",
                    field=models.TextField(blank=True),
                ),
                migrations.AddField(
                    model_name="invitelead",
                    name="sent_on",
                    field=models.DateTimeField(blank=True, null=True),
                ),
            ],
        ),
        migrations.AddField(
            model_name="evmodel",
            name="battery_capacity_kwh",
            field=models.DecimalField(
                blank=True,
                null=True,
                max_digits=6,
                decimal_places=2,
                verbose_name="Battery Capacity (kWh)",
            ),
        ),
        migrations.AddField(
            model_name="evmodel",
            name="ac_110v_power_kw",
            field=models.DecimalField(
                blank=True,
                null=True,
                max_digits=5,
                decimal_places=2,
                verbose_name="110V AC (kW)",
            ),
        ),
        migrations.AddField(
            model_name="evmodel",
            name="ac_220v_power_kw",
            field=models.DecimalField(
                blank=True,
                null=True,
                max_digits=5,
                decimal_places=2,
                verbose_name="220V AC (kW)",
            ),
        ),
        migrations.AddField(
            model_name="evmodel",
            name="dc_60_power_kw",
            field=models.DecimalField(
                blank=True,
                null=True,
                max_digits=5,
                decimal_places=2,
                verbose_name="60kW DC (kW)",
            ),
        ),
        migrations.AddField(
            model_name="evmodel",
            name="dc_100_power_kw",
            field=models.DecimalField(
                blank=True,
                null=True,
                max_digits=5,
                decimal_places=2,
                verbose_name="100kW DC (kW)",
            ),
        ),
    ]
