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

import django.db.models.deletion
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='HistoricalServer',
            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')),
                ('name', models.CharField(db_index=True, max_length=150, verbose_name='Nome')),
                ('hostname', models.CharField(blank=True, max_length=253, verbose_name='Hostname')),
                ('ip_address', models.GenericIPAddressField(blank=True, null=True, verbose_name='Endereço IP')),
                ('location', models.CharField(blank=True, max_length=120, verbose_name='Localização')),
                ('control_panel', models.CharField(blank=True, help_text='Ex.: cPanel, Plesk, DirectAdmin', max_length=80, verbose_name='Painel')),
                ('panel_url', models.URLField(blank=True, verbose_name='URL do painel')),
                ('account_reference', models.CharField(blank=True, max_length=150, verbose_name='Referência no cofre')),
                ('status', models.CharField(choices=[('active', 'Ativo'), ('maintenance', 'Em manutenção'), ('retired', 'Desativado')], default='active', max_length=20, verbose_name='Estado')),
                ('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)),
                ('provider', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='core.provider', verbose_name='Fornecedor')),
            ],
            options={
                'verbose_name': 'historical Servidor',
                'verbose_name_plural': 'historical Servidores',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='Server',
            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')),
                ('name', models.CharField(max_length=150, unique=True, verbose_name='Nome')),
                ('hostname', models.CharField(blank=True, max_length=253, verbose_name='Hostname')),
                ('ip_address', models.GenericIPAddressField(blank=True, null=True, verbose_name='Endereço IP')),
                ('location', models.CharField(blank=True, max_length=120, verbose_name='Localização')),
                ('control_panel', models.CharField(blank=True, help_text='Ex.: cPanel, Plesk, DirectAdmin', max_length=80, verbose_name='Painel')),
                ('panel_url', models.URLField(blank=True, verbose_name='URL do painel')),
                ('account_reference', models.CharField(blank=True, max_length=150, verbose_name='Referência no cofre')),
                ('status', models.CharField(choices=[('active', 'Ativo'), ('maintenance', 'Em manutenção'), ('retired', 'Desativado')], default='active', max_length=20, verbose_name='Estado')),
                ('notes', models.TextField(blank=True, verbose_name='Notas')),
                ('provider', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='servers', to='core.provider', verbose_name='Fornecedor')),
            ],
            options={
                'verbose_name': 'Servidor',
                'verbose_name_plural': 'Servidores',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='HistoricalTechnicalAsset',
            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')),
                ('asset_type', models.CharField(choices=[('website', 'Website'), ('database', 'Base de dados'), ('mailbox', 'Caixa de email'), ('panel_account', 'Conta de painel'), ('ssl', 'Certificado SSL'), ('backup', 'Backup'), ('other', 'Outro')], default='website', max_length=20, verbose_name='Tipo')),
                ('label', models.CharField(max_length=180, verbose_name='Designação')),
                ('domain_name', models.CharField(blank=True, max_length=253, verbose_name='Domínio / hostname')),
                ('document_root', models.CharField(blank=True, max_length=500, verbose_name='Pasta no servidor')),
                ('subdomain', models.CharField(blank=True, max_length=253, verbose_name='Subdomínio')),
                ('php_version', models.CharField(blank=True, max_length=30, verbose_name='Versão PHP')),
                ('cms', models.CharField(blank=True, max_length=80, verbose_name='CMS')),
                ('cms_version', models.CharField(blank=True, max_length=40, verbose_name='Versão do CMS')),
                ('ssl_active', models.BooleanField(default=False, verbose_name='SSL ativo')),
                ('last_checked_at', models.DateTimeField(blank=True, null=True, verbose_name='Última verificação')),
                ('status', models.CharField(choices=[('active', 'Ativo'), ('attention', 'Requer atenção'), ('inactive', 'Inativo'), ('unknown', 'Por confirmar')], default='unknown', max_length=20, verbose_name='Estado')),
                ('notes', models.TextField(blank=True, verbose_name='Notas técnicas')),
                ('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)),
                ('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')),
                ('server', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='technical.server', verbose_name='Servidor')),
            ],
            options={
                'verbose_name': 'historical Ativo técnico',
                'verbose_name_plural': 'historical Ativos técnicos',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='TechnicalAsset',
            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')),
                ('asset_type', models.CharField(choices=[('website', 'Website'), ('database', 'Base de dados'), ('mailbox', 'Caixa de email'), ('panel_account', 'Conta de painel'), ('ssl', 'Certificado SSL'), ('backup', 'Backup'), ('other', 'Outro')], default='website', max_length=20, verbose_name='Tipo')),
                ('label', models.CharField(max_length=180, verbose_name='Designação')),
                ('domain_name', models.CharField(blank=True, max_length=253, verbose_name='Domínio / hostname')),
                ('document_root', models.CharField(blank=True, max_length=500, verbose_name='Pasta no servidor')),
                ('subdomain', models.CharField(blank=True, max_length=253, verbose_name='Subdomínio')),
                ('php_version', models.CharField(blank=True, max_length=30, verbose_name='Versão PHP')),
                ('cms', models.CharField(blank=True, max_length=80, verbose_name='CMS')),
                ('cms_version', models.CharField(blank=True, max_length=40, verbose_name='Versão do CMS')),
                ('ssl_active', models.BooleanField(default=False, verbose_name='SSL ativo')),
                ('last_checked_at', models.DateTimeField(blank=True, null=True, verbose_name='Última verificação')),
                ('status', models.CharField(choices=[('active', 'Ativo'), ('attention', 'Requer atenção'), ('inactive', 'Inativo'), ('unknown', 'Por confirmar')], default='unknown', max_length=20, verbose_name='Estado')),
                ('notes', models.TextField(blank=True, verbose_name='Notas técnicas')),
                ('server', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assets', to='technical.server', verbose_name='Servidor')),
                ('service', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='technical_assets', to='services.service', verbose_name='Serviço')),
            ],
            options={
                'verbose_name': 'Ativo técnico',
                'verbose_name_plural': 'Ativos técnicos',
                'ordering': ['service__client__name', 'label'],
            },
        ),
        migrations.CreateModel(
            name='HistoricalDatabaseAsset',
            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')),
                ('name', models.CharField(max_length=180, verbose_name='Nome da base de dados')),
                ('engine', models.CharField(choices=[('mysql', 'MySQL / MariaDB'), ('postgres', 'PostgreSQL'), ('sqlite', 'SQLite'), ('other', 'Outro')], default='mysql', max_length=20, verbose_name='Motor')),
                ('size_mb', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True, verbose_name='Tamanho (MB)')),
                ('username_reference', models.CharField(blank=True, max_length=150, verbose_name='Referência do utilizador')),
                ('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)),
                ('technical_asset', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='technical.technicalasset', verbose_name='Ativo técnico')),
            ],
            options={
                'verbose_name': 'historical Base de dados',
                'verbose_name_plural': 'historical Bases de dados',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalBackupRecord',
            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')),
                ('backup_type', models.CharField(choices=[('full', 'Completo'), ('files', 'Ficheiros'), ('database', 'Base de dados'), ('incremental', 'Incremental')], default='full', max_length=20, verbose_name='Tipo')),
                ('backup_date', models.DateTimeField(verbose_name='Data do backup')),
                ('location_reference', models.CharField(blank=True, max_length=300, verbose_name='Localização / referência')),
                ('size_mb', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True, verbose_name='Tamanho (MB)')),
                ('verified_at', models.DateTimeField(blank=True, null=True, verbose_name='Verificado em')),
                ('status', models.CharField(choices=[('created', 'Criado'), ('verified', 'Verificado'), ('failed', 'Falhou'), ('expired', 'Expirado')], default='created', max_length=20, verbose_name='Estado')),
                ('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)),
                ('technical_asset', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='technical.technicalasset', verbose_name='Ativo técnico')),
            ],
            options={
                'verbose_name': 'historical Backup',
                'verbose_name_plural': 'historical Backups',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='DatabaseAsset',
            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')),
                ('name', models.CharField(max_length=180, verbose_name='Nome da base de dados')),
                ('engine', models.CharField(choices=[('mysql', 'MySQL / MariaDB'), ('postgres', 'PostgreSQL'), ('sqlite', 'SQLite'), ('other', 'Outro')], default='mysql', max_length=20, verbose_name='Motor')),
                ('size_mb', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True, verbose_name='Tamanho (MB)')),
                ('username_reference', models.CharField(blank=True, max_length=150, verbose_name='Referência do utilizador')),
                ('notes', models.TextField(blank=True, verbose_name='Notas')),
                ('technical_asset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='databases', to='technical.technicalasset', verbose_name='Ativo técnico')),
            ],
            options={
                'verbose_name': 'Base de dados',
                'verbose_name_plural': 'Bases de dados',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='BackupRecord',
            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')),
                ('backup_type', models.CharField(choices=[('full', 'Completo'), ('files', 'Ficheiros'), ('database', 'Base de dados'), ('incremental', 'Incremental')], default='full', max_length=20, verbose_name='Tipo')),
                ('backup_date', models.DateTimeField(verbose_name='Data do backup')),
                ('location_reference', models.CharField(blank=True, max_length=300, verbose_name='Localização / referência')),
                ('size_mb', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True, verbose_name='Tamanho (MB)')),
                ('verified_at', models.DateTimeField(blank=True, null=True, verbose_name='Verificado em')),
                ('status', models.CharField(choices=[('created', 'Criado'), ('verified', 'Verificado'), ('failed', 'Falhou'), ('expired', 'Expirado')], default='created', max_length=20, verbose_name='Estado')),
                ('notes', models.TextField(blank=True, verbose_name='Notas')),
                ('technical_asset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='backups', to='technical.technicalasset', verbose_name='Ativo técnico')),
            ],
            options={
                'verbose_name': 'Backup',
                'verbose_name_plural': 'Backups',
                'ordering': ['-backup_date'],
            },
        ),
    ]
