# Generated by Django 5.2.5 on 2025-09-02 19:19

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Node',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, unique=True, verbose_name='节点名称')),
                ('ip', models.GenericIPAddressField(verbose_name='IP地址')),
                ('port', models.IntegerField(blank=True, default=6800, null=True)),
                ('ssl', models.BooleanField(default=False, verbose_name='是否启用SSL')),
                ('description', models.CharField(blank=True, max_length=500, null=True, verbose_name='描述')),
                ('auth', models.BooleanField(default=False, verbose_name='是否需要认证')),
                ('username', models.CharField(blank=True, max_length=255, null=True)),
                ('password', models.CharField(blank=True, max_length=255, null=True)),
                ('create_time', models.DateTimeField(default=datetime.datetime.now, verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
            ],
            options={
                'verbose_name': 'Scrapyd Node',
                'verbose_name_plural': 'Scrapyd Node',
                'db_table': 'scrapyd_node',
                'ordering': ['-create_time'],
            },
        ),
        migrations.CreateModel(
            name='Project',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255, verbose_name='项目名')),
                ('is_deleted', models.BooleanField(default=False, verbose_name='是否已被删除')),
                ('create_time', models.DateTimeField(default=datetime.datetime.now, verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('node', models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, related_name='projects', to='django_scrapyd_manager.node', verbose_name='节点')),
            ],
            options={
                'verbose_name': 'Scrapy Project',
                'verbose_name_plural': 'Scrapy Project',
                'db_table': 'scrapy_project',
                'unique_together': {('node', 'name')},
            },
        ),
        migrations.CreateModel(
            name='ProjectVersion',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('version', models.CharField(max_length=255, verbose_name='版本')),
                ('is_spider_synced', models.BooleanField(default=False, verbose_name='是否已同步当前版本爬虫')),
                ('is_deleted', models.BooleanField(default=False, verbose_name='是否已被删除')),
                ('create_time', models.DateTimeField(default=datetime.datetime.now, verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('project', models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, related_name='versions', to='django_scrapyd_manager.project', verbose_name='项目')),
            ],
            options={
                'verbose_name': 'Scrapy Project Version',
                'verbose_name_plural': 'Scrapy Project Version',
                'db_table': 'scrapy_project_version',
                'ordering': ['-version'],
                'unique_together': {('project', 'version')},
            },
        ),
        migrations.CreateModel(
            name='Spider',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255, verbose_name='爬虫名称')),
                ('create_time', models.DateTimeField(default=datetime.datetime.now, verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('version', models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, related_name='spiders', to='django_scrapyd_manager.projectversion', verbose_name='版本')),
            ],
            options={
                'verbose_name': 'Scrapy Spider',
                'verbose_name_plural': 'Scrapy Spider',
                'db_table': 'scrapy_spider',
                'ordering': ['-version', 'name'],
                'unique_together': {('version', 'name')},
            },
        ),
        migrations.CreateModel(
            name='Job',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('job_id', models.CharField(max_length=255, verbose_name='任务ID')),
                ('job_md5', models.CharField(max_length=32, unique=True, verbose_name='md5(job)')),
                ('start_time', models.DateTimeField(verbose_name='开始时间')),
                ('end_time', models.DateTimeField(blank=True, null=True, verbose_name='结束时间')),
                ('log_url', models.CharField(blank=True, max_length=255, null=True)),
                ('items_url', models.CharField(blank=True, max_length=255, null=True)),
                ('status', models.CharField(choices=[('running', '运行中'), ('finished', '已结束'), ('pending', '启动中')], max_length=20, verbose_name='状态')),
                ('pid', models.IntegerField(blank=True, null=True, verbose_name='进程ID')),
                ('create_time', models.DateTimeField(default=datetime.datetime.now, verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('spider', models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, related_name='jobs', to='django_scrapyd_manager.spider', verbose_name='爬虫')),
            ],
            options={
                'verbose_name': 'Scrapy Job',
                'verbose_name_plural': 'Scrapy Job',
                'db_table': 'scrapy_job',
            },
        ),
        migrations.CreateModel(
            name='SpiderGroup',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255, unique=True, verbose_name='任务组名称')),
                ('spiders', models.JSONField(default=list, verbose_name='爬虫')),
                ('kwargs', models.JSONField(blank=True, default=dict, null=True, verbose_name='参数')),
                ('description', models.CharField(blank=True, max_length=200, null=True, verbose_name='任务组描述')),
                ('create_time', models.DateTimeField(default=datetime.datetime.now, verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('node', models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, to='django_scrapyd_manager.node', verbose_name='节点')),
                ('project', models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to='django_scrapyd_manager.project', verbose_name='项目')),
                ('version', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='django_scrapyd_manager.projectversion', verbose_name='版本')),
            ],
            options={
                'verbose_name': 'Scrapy Spider Group',
                'verbose_name_plural': 'Scrapy Spider Group',
                'db_table': 'scrapy_spider_group',
            },
        ),
    ]
