# Generated by Django 3.2.12 on 2022-05-24 12:55

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models

import baserow.core.jobs.models
import baserow.core.mixins


class Migration(migrations.Migration):
    dependencies = [
        ("contenttypes", "0002_remove_content_type_name"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("core", "0024_group_storage_usage"),
    ]

    operations = [
        migrations.CreateModel(
            name="Job",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_on", models.DateTimeField(auto_now_add=True)),
                ("updated_on", models.DateTimeField(auto_now=True)),
                (
                    "progress_percentage",
                    models.IntegerField(
                        default=0,
                        help_text="A percentage indicating how far along the job is. "
                        "100 means that it's finished.",
                    ),
                ),
                (
                    "state",
                    models.CharField(
                        db_index=True,
                        default="pending",
                        help_text="Indicates the state of the job.",
                        max_length=128,
                    ),
                ),
                (
                    "error",
                    models.TextField(
                        blank=True,
                        default="",
                        help_text="An error message if something went wrong.",
                    ),
                ),
                (
                    "human_readable_error",
                    models.TextField(
                        blank=True,
                        default="",
                        help_text="A human readable error message indicating what "
                        "went wrong.",
                    ),
                ),
                (
                    "content_type",
                    models.ForeignKey(
                        on_delete=models.SET(
                            baserow.core.jobs.models.get_default_job_content_type
                        ),
                        related_name="database_jobs",
                        to="contenttypes.contenttype",
                        verbose_name="content type",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        help_text="The user that has created the job",
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ("id",),
            },
            bases=(baserow.core.mixins.PolymorphicContentTypeMixin, models.Model),
        ),
    ]
