# Generated by Django 5.2.7 on 2026-01-02 04:45

from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Target',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(blank=True, default='', help_text='目标标识（域名/IP/CIDR）', max_length=300)),
                ('type', models.CharField(choices=[('domain', '域名'), ('ip', 'IP地址'), ('cidr', 'CIDR范围')], db_index=True, default='domain', help_text='目标类型', max_length=20)),
                ('created_at', models.DateTimeField(auto_now_add=True, help_text='创建时间')),
                ('last_scanned_at', models.DateTimeField(blank=True, help_text='最后扫描时间', null=True)),
                ('deleted_at', models.DateTimeField(blank=True, db_index=True, help_text='删除时间（NULL表示未删除）', null=True)),
            ],
            options={
                'verbose_name': '扫描目标',
                'verbose_name_plural': '扫描目标',
                'db_table': 'target',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['type'], name='target_type_36a73c_idx'), models.Index(fields=['-created_at'], name='target_created_67f489_idx'), models.Index(fields=['deleted_at', '-created_at'], name='target_deleted_9fc9da_idx'), models.Index(fields=['deleted_at', 'type'], name='target_deleted_306a89_idx'), models.Index(fields=['name'], name='target_name_f1c641_idx')],
                'constraints': [models.UniqueConstraint(condition=models.Q(('deleted_at__isnull', True)), fields=('name',), name='unique_target_name_active')],
            },
        ),
        migrations.CreateModel(
            name='Organization',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(blank=True, default='', help_text='组织名称', max_length=300)),
                ('description', models.CharField(blank=True, default='', help_text='组织描述', max_length=1000)),
                ('created_at', models.DateTimeField(auto_now_add=True, help_text='创建时间')),
                ('deleted_at', models.DateTimeField(blank=True, db_index=True, help_text='删除时间（NULL表示未删除）', null=True)),
                ('targets', models.ManyToManyField(blank=True, help_text='所属目标列表', related_name='organizations', to='targets.target')),
            ],
            options={
                'verbose_name': '组织',
                'verbose_name_plural': '组织',
                'db_table': 'organization',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['-created_at'], name='organizatio_created_012eac_idx'), models.Index(fields=['deleted_at', '-created_at'], name='organizatio_deleted_2c604f_idx'), models.Index(fields=['name'], name='organizatio_name_bcc2ee_idx')],
                'constraints': [models.UniqueConstraint(condition=models.Q(('deleted_at__isnull', True)), fields=('name',), name='unique_organization_name_active')],
            },
        ),
    ]
