# Generated by Django 6.1 on 2026-08-18 05:25

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('domains', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Batch',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('kind', models.CharField(choices=[('SITEMAP_SYNC', 'Sincronización de sitemaps'), ('URL_INSPECTION', 'Inspección de URLs')], max_length=20)),
                ('origin', models.CharField(choices=[('SCHEDULED', 'Programado'), ('MANUAL', 'Manual'), ('API', 'API')], max_length=20)),
                ('state', models.CharField(choices=[('QUEUED', 'En cola'), ('RUNNING', 'En curso'), ('COMPLETED', 'Terminado'), ('PARTIAL', 'Terminado con pendientes'), ('FAILED', 'Fallido')], default='QUEUED', max_length=20)),
                ('total_items', models.PositiveIntegerField(default=0)),
                ('processed_items', models.PositiveIntegerField(default=0)),
                ('failed_items', models.PositiveIntegerField(default=0)),
                ('quota_consumed', models.PositiveIntegerField(default=0)),
                ('started_at', models.DateTimeField(blank=True, null=True)),
                ('finished_at', models.DateTimeField(blank=True, null=True)),
                ('idempotency_key', models.CharField(blank=True, max_length=255, null=True)),
                ('summary', models.JSONField(blank=True, default=dict)),
                ('domain', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='batches', to='domains.domain')),
            ],
            options={
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['domain', 'state'], name='jobs_batch_domain__06b540_idx')],
                'constraints': [models.UniqueConstraint(condition=models.Q(('idempotency_key__isnull', False)), fields=('domain', 'idempotency_key'), name='una_clave_de_idempotencia_por_dominio')],
            },
        ),
        migrations.CreateModel(
            name='QuotaBudget',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('date', models.DateField()),
                ('limit_total', models.PositiveIntegerField()),
                ('manual_reserve', models.PositiveIntegerField()),
                ('used_automatic', models.PositiveIntegerField(default=0)),
                ('used_manual', models.PositiveIntegerField(default=0)),
                ('domain', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quota_budgets', to='domains.domain')),
            ],
            options={
                'ordering': ['-date'],
                'constraints': [models.UniqueConstraint(fields=('domain', 'date'), name='un_presupuesto_por_dia')],
            },
        ),
    ]
