# Generated by Django 5.2.15 on 2026-06-15 08:28

import django.db.models.deletion
import domains.validators
import simple_history.models
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('core', '0001_initial'),
        ('services', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Domain',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('public_id', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Criado em')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Atualizado em')),
                ('domain_name', models.CharField(db_index=True, max_length=253, unique=True, validators=[domains.validators.validate_domain_name], verbose_name='Domínio')),
                ('registered_on', models.DateField(blank=True, null=True, verbose_name='Data de criação')),
                ('status', models.CharField(choices=[('active', 'Ativo'), ('expiring', 'A expirar'), ('expired', 'Expirado'), ('transferred', 'Transferido'), ('cancelled', 'Cancelado'), ('complimentary', 'Oferta'), ('client_direct', 'Pago diretamente pelo cliente')], db_index=True, default='active', max_length=20, verbose_name='Estado do domínio')),
                ('auto_renew_at_registrar', models.BooleanField(default=False, verbose_name='Auto-renovação no registador')),
                ('dns_management', models.CharField(choices=[('internal', 'Gerido internamente'), ('registrar', 'Gerido no registador'), ('client', 'Gerido pelo cliente'), ('external', 'Fornecedor externo'), ('unknown', 'Por confirmar')], default='unknown', max_length=20, verbose_name='Gestão DNS')),
                ('nameservers', models.TextField(blank=True, help_text='Um nameserver por linha.', verbose_name='Nameservers')),
                ('transfer_lock', models.BooleanField(default=True, verbose_name='Bloqueio de transferência')),
                ('auth_code_reference', models.CharField(blank=True, help_text='Não guardar o código; indicar apenas onde está guardado.', max_length=150, verbose_name='Referência do AuthCode')),
                ('notes', models.TextField(blank=True, verbose_name='Notas')),
                ('registrar', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='domains', to='core.provider', verbose_name='Registador')),
                ('service', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='domain_details', to='services.service', verbose_name='Serviço')),
            ],
            options={
                'verbose_name': 'Domínio',
                'verbose_name_plural': 'Domínios',
                'ordering': ['domain_name'],
            },
        ),
        migrations.CreateModel(
            name='HistoricalDomain',
            fields=[
                ('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('public_id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
                ('created_at', models.DateTimeField(blank=True, editable=False, verbose_name='Criado em')),
                ('updated_at', models.DateTimeField(blank=True, editable=False, verbose_name='Atualizado em')),
                ('domain_name', models.CharField(db_index=True, max_length=253, validators=[domains.validators.validate_domain_name], verbose_name='Domínio')),
                ('registered_on', models.DateField(blank=True, null=True, verbose_name='Data de criação')),
                ('status', models.CharField(choices=[('active', 'Ativo'), ('expiring', 'A expirar'), ('expired', 'Expirado'), ('transferred', 'Transferido'), ('cancelled', 'Cancelado'), ('complimentary', 'Oferta'), ('client_direct', 'Pago diretamente pelo cliente')], db_index=True, default='active', max_length=20, verbose_name='Estado do domínio')),
                ('auto_renew_at_registrar', models.BooleanField(default=False, verbose_name='Auto-renovação no registador')),
                ('dns_management', models.CharField(choices=[('internal', 'Gerido internamente'), ('registrar', 'Gerido no registador'), ('client', 'Gerido pelo cliente'), ('external', 'Fornecedor externo'), ('unknown', 'Por confirmar')], default='unknown', max_length=20, verbose_name='Gestão DNS')),
                ('nameservers', models.TextField(blank=True, help_text='Um nameserver por linha.', verbose_name='Nameservers')),
                ('transfer_lock', models.BooleanField(default=True, verbose_name='Bloqueio de transferência')),
                ('auth_code_reference', models.CharField(blank=True, help_text='Não guardar o código; indicar apenas onde está guardado.', max_length=150, verbose_name='Referência do AuthCode')),
                ('notes', models.TextField(blank=True, verbose_name='Notas')),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField(db_index=True)),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('registrar', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='core.provider', verbose_name='Registador')),
                ('service', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='services.service', verbose_name='Serviço')),
            ],
            options={
                'verbose_name': 'historical Domínio',
                'verbose_name_plural': 'historical Domínios',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
    ]
