# Generated by Django 4.2.14 on 2024-07-16 09:22

from django.conf import settings
from django.db import migrations, models
import django.utils.timezone
import uuid


class Migration(migrations.Migration):

    replaces = [
        ('bgjobs', '0001_initial'),
        ('bgjobs', '0002_backgroundjoblogentry'),
        ('bgjobs', '0003_backgroundjob_date_created'),
        ('bgjobs', '0004_backgroundjob_user'),
        ('bgjobs', '0005_auto_20190128_1210'),
        ('bgjobs', '0006_auto_20200526_1657'),
    ]

    initial = True

    dependencies = [
        ('projectroles', '0005_update_uuid'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='BackgroundJob',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                (
                    'date_modified',
                    models.DateTimeField(
                        auto_now=True, help_text='DateTime of last modification'
                    ),
                ),
                (
                    'sodar_uuid',
                    models.UUIDField(
                        default=uuid.uuid4,
                        help_text='BG Job SODAR UUID',
                        unique=True,
                    ),
                ),
                (
                    'job_type',
                    models.CharField(
                        help_text='Type of the job', max_length=512
                    ),
                ),
                ('name', models.CharField(max_length=512)),
                ('description', models.TextField()),
                (
                    'status',
                    models.CharField(
                        choices=[
                            ('initial', 'initial'),
                            ('running', 'running'),
                            ('done', 'done'),
                            ('failed', 'failed'),
                        ],
                        default='initial',
                        max_length=50,
                    ),
                ),
                (
                    'project',
                    models.ForeignKey(
                        help_text='Project in which this objects belongs',
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to='projectroles.project',
                    ),
                ),
                (
                    'date_created',
                    models.DateTimeField(
                        auto_now_add=True,
                        help_text='DateTime of creation',
                    ),
                ),
                (
                    'user',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='background_jobs',
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                'ordering': ['-date_created'],
            },
        ),
        migrations.CreateModel(
            name='BackgroundJobLogEntry',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                (
                    'date_created',
                    models.DateTimeField(
                        auto_now_add=True, help_text='DateTime of creation'
                    ),
                ),
                (
                    'level',
                    models.CharField(
                        choices=[
                            ('debug', 'debug'),
                            ('info', 'info'),
                            ('warning', 'warning'),
                            ('error', 'error'),
                        ],
                        help_text='Level of log entry',
                        max_length=50,
                    ),
                ),
                ('message', models.TextField(help_text='Log level\'s message')),
                (
                    'job',
                    models.ForeignKey(
                        help_text='Owning background job',
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='log_entries',
                        to='bgjobs.backgroundjob',
                    ),
                ),
            ],
            options={
                'ordering': ['date_created'],
            },
        ),
    ]
