# Generated by Django 4.1.4 on 2023-01-02 03:54

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

import stator.models
import users.models.domain


class Migration(migrations.Migration):

    dependencies = [
        ("users", "0009_state_and_post_indexes"),
    ]

    operations = [
        migrations.AddField(
            model_name="domain",
            name="nodeinfo",
            field=models.JSONField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="domain",
            name="state",
            field=stator.models.StateField(
                choices=[
                    ("outdated", "outdated"),
                    ("updated", "updated"),
                    ("connection_issue", "connection_issue"),
                    ("purged", "purged"),
                ],
                default="outdated",
                graph=users.models.domain.DomainStates,
                max_length=100,
            ),
        ),
        migrations.AddField(
            model_name="domain",
            name="state_attempted",
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="domain",
            name="state_changed",
            field=models.DateTimeField(
                auto_now_add=True, default=django.utils.timezone.now
            ),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="domain",
            name="state_locked_until",
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="domain",
            name="state_ready",
            field=models.BooleanField(default=True),
        ),
        migrations.AddIndex(
            model_name="domain",
            index=models.Index(
                fields=["state", "state_attempted"], name="ix_domain_state_attempted"
            ),
        ),
        migrations.AddIndex(
            model_name="domain",
            index=models.Index(
                condition=models.Q(("state_locked_until__isnull", False)),
                fields=["state_locked_until", "state"],
                name="ix_domain_state_locked",
            ),
        ),
    ]
