# Generated by Django 5.2 on 2025-04-13 20:24

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


class Migration(migrations.Migration):
    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="HealthCheck",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "check_type",
                    models.CharField(
                        choices=[
                            ("http", "HTTP"),
                            ("tcp", "TCP"),
                            ("ping", "Ping"),
                            ("dns", "DNS"),
                            ("custom", "Custom"),
                        ],
                        default="http",
                        max_length=20,
                        verbose_name="Check Type",
                    ),
                ),
                ("url", models.URLField(max_length=512, verbose_name="URL")),
                (
                    "check_interval",
                    models.IntegerField(
                        choices=[
                            (30, "30 seconds"),
                            (60, "1 minute"),
                            (300, "5 minutes"),
                            (900, "15 minutes"),
                            (1800, "30 minutes"),
                            (3600, "1 hour"),
                            (86400, "1 day"),
                        ],
                        default=300,
                        help_text="How often this health check should be performed",
                        verbose_name="Check Interval",
                    ),
                ),
            ],
            options={
                "db_table": "health_check",
            },
        ),
        migrations.CreateModel(
            name="Service",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=255, verbose_name="Service Name")),
            ],
            options={
                "db_table": "service",
            },
        ),
        migrations.CreateModel(
            name="Result",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[("ok", "OK"), ("error", "Error")],
                        max_length=10,
                        verbose_name="Status",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
                ),
                (
                    "data",
                    models.JSONField(blank=True, default=dict, verbose_name="Metadata"),
                ),
                (
                    "health_check",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="results",
                        to="nyxboard.healthcheck",
                    ),
                ),
            ],
            options={
                "db_table": "check_result",
            },
        ),
        migrations.AddField(
            model_name="healthcheck",
            name="service",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE, to="nyxboard.service"
            ),
        ),
    ]
