# Generated by Django 2.2.2 on 2019-08-21 07:41

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='ScrapydProject',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=256)),
            ],
            options={
                'db_table': 'scrapyd_dash_projects',
            },
        ),
        migrations.CreateModel(
            name='ScrapydServer',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('ip', models.CharField(max_length=128)),
                ('port', models.CharField(max_length=32)),
                ('node_name', models.CharField(max_length=256)),
                ('status', models.CharField(max_length=64)),
                ('status_message', models.CharField(max_length=512, null=True)),
                ('pending_tasks', models.PositiveIntegerField(default=0)),
                ('finished_tasks', models.PositiveIntegerField(default=0)),
                ('running_tasks', models.PositiveIntegerField(default=0)),
            ],
            options={
                'db_table': 'scrapyd_dash_servers',
                'ordering': ['-status'],
                'unique_together': {('ip', 'port')},
            },
        ),
        migrations.CreateModel(
            name='Task',
            fields=[
                ('id', models.CharField(max_length=64, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=256)),
                ('spider', models.CharField(max_length=256)),
                ('status', models.CharField(max_length=64)),
                ('pages', models.PositiveIntegerField(null=True)),
                ('items', models.PositiveIntegerField(null=True)),
                ('pid', models.PositiveIntegerField(null=True)),
                ('runtime', models.CharField(blank=True, max_length=64, null=True)),
                ('start_datetime', models.DateTimeField(blank=True, null=True)),
                ('finished_datetime', models.DateTimeField(blank=True, null=True)),
                ('log_href', models.CharField(max_length=1024, null=True)),
                ('items_href', models.CharField(max_length=1024, null=True)),
                ('create_datetime', models.DateTimeField(auto_now_add=True)),
                ('update_datetime', models.DateTimeField(auto_now=True)),
                ('deleted', models.BooleanField(default=False)),
                ('stopping', models.BooleanField(default=False)),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='scrapyd_dash.ScrapydProject')),
                ('server', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='scrapyd_dash.ScrapydServer')),
            ],
            options={
                'db_table': 'scrapyd_dash_tasks',
                'ordering': ['-create_datetime'],
            },
        ),
        migrations.CreateModel(
            name='ScrapydProjectVersion',
            fields=[
                ('version', models.CharField(max_length=125, primary_key=True, serialize=False)),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='scrapyd_dash.ScrapydProject')),
            ],
        ),
        migrations.AddField(
            model_name='scrapydproject',
            name='server',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='scrapyd_dash.ScrapydServer'),
        ),
        migrations.CreateModel(
            name='ScheduledTask',
            fields=[
                ('name', models.CharField(max_length=256, primary_key=True, serialize=False)),
                ('create_datetime', models.DateTimeField(auto_now_add=True)),
                ('update_datetime', models.DateTimeField(auto_now=True)),
                ('spider', models.CharField(max_length=256)),
                ('year', models.PositiveIntegerField(blank=True, null=True)),
                ('month', models.PositiveIntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(12)])),
                ('day', models.PositiveIntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(32)])),
                ('week', models.PositiveIntegerField(blank=True, null=True)),
                ('day_of_week', models.PositiveIntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(7)])),
                ('hour', models.PositiveIntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(24)])),
                ('minute', models.PositiveIntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(60)])),
                ('last_run', models.DateTimeField(blank=True, null=True)),
                ('next_run', models.DateTimeField(blank=True, null=True)),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='scrapyd_dash.ScrapydProject')),
                ('server', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='scrapyd_dash.ScrapydServer')),
                ('tasks', models.ManyToManyField(blank=True, to='scrapyd_dash.Task')),
            ],
            options={
                'db_table': 'scrapyd_dash_scheduled_tasks',
                'ordering': ['-create_datetime'],
            },
        ),
        migrations.AlterUniqueTogether(
            name='scrapydproject',
            unique_together={('server', 'name')},
        ),
    ]
