# Generated by Plain 0.52.2 on 2025-07-08 01:17

import uuid

from plain import postgres
from plain.postgres import migrations


class Migration(migrations.Migration):
    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="Job",
            fields=[
                ("id", postgres.PrimaryKeyField()),
                ("uuid", postgres.UUIDField(default=uuid.uuid4)),
                ("created_at", postgres.DateTimeField(auto_now_add=True)),
                ("started_at", postgres.DateTimeField(allow_null=True, required=False)),
                ("job_request_uuid", postgres.UUIDField()),
                ("job_class", postgres.TextField(max_length=255)),
                ("parameters", postgres.JSONField(allow_null=True, required=False)),
                ("priority", postgres.IntegerField(default=0)),
                ("source", postgres.TextField(required=False)),
                ("queue", postgres.TextField(default="default", max_length=255)),
                ("retries", postgres.IntegerField(default=0)),
                ("retry_attempt", postgres.IntegerField(default=0)),
                ("unique_key", postgres.TextField(max_length=255, required=False)),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="JobRequest",
            fields=[
                ("id", postgres.PrimaryKeyField()),
                ("created_at", postgres.DateTimeField(auto_now_add=True)),
                ("uuid", postgres.UUIDField(default=uuid.uuid4)),
                ("job_class", postgres.TextField(max_length=255)),
                ("parameters", postgres.JSONField(allow_null=True, required=False)),
                ("priority", postgres.IntegerField(default=0)),
                ("source", postgres.TextField(required=False)),
                ("queue", postgres.TextField(default="default", max_length=255)),
                ("retries", postgres.IntegerField(default=0)),
                ("retry_attempt", postgres.IntegerField(default=0)),
                ("unique_key", postgres.TextField(max_length=255, required=False)),
                ("start_at", postgres.DateTimeField(allow_null=True, required=False)),
            ],
            options={
                "ordering": ["priority", "-created_at"],
            },
        ),
        migrations.CreateModel(
            name="JobResult",
            fields=[
                ("id", postgres.PrimaryKeyField()),
                ("uuid", postgres.UUIDField(default=uuid.uuid4)),
                ("created_at", postgres.DateTimeField(auto_now_add=True)),
                ("job_uuid", postgres.UUIDField()),
                ("started_at", postgres.DateTimeField(allow_null=True, required=False)),
                ("ended_at", postgres.DateTimeField(allow_null=True, required=False)),
                ("error", postgres.TextField(required=False)),
                (
                    "status",
                    postgres.TextField(
                        choices=[
                            ("SUCCESSFUL", "Successful"),
                            ("ERRORED", "Errored"),
                            ("CANCELLED", "Cancelled"),
                            ("LOST", "Lost"),
                        ],
                        max_length=20,
                    ),
                ),
                ("job_request_uuid", postgres.UUIDField()),
                ("job_class", postgres.TextField(max_length=255)),
                ("parameters", postgres.JSONField(allow_null=True, required=False)),
                ("priority", postgres.IntegerField(default=0)),
                ("source", postgres.TextField(required=False)),
                ("queue", postgres.TextField(default="default", max_length=255)),
                ("retries", postgres.IntegerField(default=0)),
                ("retry_attempt", postgres.IntegerField(default=0)),
                ("unique_key", postgres.TextField(max_length=255, required=False)),
                (
                    "retry_job_request_uuid",
                    postgres.UUIDField(allow_null=True, required=False),
                ),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
    ]
