# Generated by Django 5.1.6 on 2025-12-26 20:01

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

import apps.core.state_machine.fields


class Migration(migrations.Migration):

    dependencies = [
        ("moderation", "0008_alter_bulkoperation_options_and_more"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        pgtrigger.migrations.RemoveTrigger(
            model_name="editsubmission",
            name="insert_insert",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="editsubmission",
            name="update_update",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="photosubmission",
            name="insert_insert",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="photosubmission",
            name="update_update",
        ),
        migrations.AddField(
            model_name="editsubmission",
            name="claimed_at",
            field=models.DateTimeField(blank=True, help_text="When this submission was claimed", null=True),
        ),
        migrations.AddField(
            model_name="editsubmission",
            name="claimed_by",
            field=models.ForeignKey(
                blank=True,
                help_text="Moderator who has claimed this submission for review",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="claimed_edit_submissions",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="editsubmissionevent",
            name="claimed_at",
            field=models.DateTimeField(blank=True, help_text="When this submission was claimed", null=True),
        ),
        migrations.AddField(
            model_name="editsubmissionevent",
            name="claimed_by",
            field=models.ForeignKey(
                blank=True,
                db_constraint=False,
                help_text="Moderator who has claimed this submission for review",
                null=True,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                related_query_name="+",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="photosubmission",
            name="claimed_at",
            field=models.DateTimeField(blank=True, help_text="When this submission was claimed", null=True),
        ),
        migrations.AddField(
            model_name="photosubmission",
            name="claimed_by",
            field=models.ForeignKey(
                blank=True,
                help_text="Moderator who has claimed this submission for review",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="claimed_photo_submissions",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="photosubmissionevent",
            name="claimed_at",
            field=models.DateTimeField(blank=True, help_text="When this submission was claimed", null=True),
        ),
        migrations.AddField(
            model_name="photosubmissionevent",
            name="claimed_by",
            field=models.ForeignKey(
                blank=True,
                db_constraint=False,
                help_text="Moderator who has claimed this submission for review",
                null=True,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                related_query_name="+",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AlterField(
            model_name="editsubmissionevent",
            name="status",
            field=apps.core.state_machine.fields.RichFSMField(
                allow_deprecated=False,
                choice_group="edit_submission_statuses",
                choices=[
                    ("PENDING", "Pending"),
                    ("CLAIMED", "Claimed"),
                    ("APPROVED", "Approved"),
                    ("REJECTED", "Rejected"),
                    ("ESCALATED", "Escalated"),
                ],
                default="PENDING",
                domain="moderation",
                max_length=20,
            ),
        ),
        migrations.AlterField(
            model_name="photosubmissionevent",
            name="status",
            field=apps.core.state_machine.fields.RichFSMField(
                allow_deprecated=False,
                choice_group="photo_submission_statuses",
                choices=[
                    ("PENDING", "Pending"),
                    ("CLAIMED", "Claimed"),
                    ("APPROVED", "Approved"),
                    ("REJECTED", "Rejected"),
                    ("ESCALATED", "Escalated"),
                ],
                default="PENDING",
                domain="moderation",
                max_length=20,
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="editsubmission",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "moderation_editsubmissionevent" ("changes", "claimed_at", "claimed_by_id", "content_type_id", "created_at", "handled_at", "handled_by_id", "id", "moderator_changes", "notes", "object_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "reason", "source", "status", "submission_type", "updated_at", "user_id") VALUES (NEW."changes", NEW."claimed_at", NEW."claimed_by_id", NEW."content_type_id", NEW."created_at", NEW."handled_at", NEW."handled_by_id", NEW."id", NEW."moderator_changes", NEW."notes", NEW."object_id", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."reason", NEW."source", NEW."status", NEW."submission_type", NEW."updated_at", NEW."user_id"); RETURN NULL;',
                    hash="947e1d596310a6e4aad4f30724fbd2e2294d977b",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_2c796",
                    table="moderation_editsubmission",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="editsubmission",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "moderation_editsubmissionevent" ("changes", "claimed_at", "claimed_by_id", "content_type_id", "created_at", "handled_at", "handled_by_id", "id", "moderator_changes", "notes", "object_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "reason", "source", "status", "submission_type", "updated_at", "user_id") VALUES (NEW."changes", NEW."claimed_at", NEW."claimed_by_id", NEW."content_type_id", NEW."created_at", NEW."handled_at", NEW."handled_by_id", NEW."id", NEW."moderator_changes", NEW."notes", NEW."object_id", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."reason", NEW."source", NEW."status", NEW."submission_type", NEW."updated_at", NEW."user_id"); RETURN NULL;',
                    hash="568618c5161ed78a9c72d751f1c312c64dea3994",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_ab38f",
                    table="moderation_editsubmission",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="photosubmission",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "moderation_photosubmissionevent" ("caption", "claimed_at", "claimed_by_id", "content_type_id", "created_at", "date_taken", "handled_at", "handled_by_id", "id", "notes", "object_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "photo_id", "status", "updated_at", "user_id") VALUES (NEW."caption", NEW."claimed_at", NEW."claimed_by_id", NEW."content_type_id", NEW."created_at", NEW."date_taken", NEW."handled_at", NEW."handled_by_id", NEW."id", NEW."notes", NEW."object_id", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."photo_id", NEW."status", NEW."updated_at", NEW."user_id"); RETURN NULL;',
                    hash="483cca8949361fe83eb0a964f9f454c5d2c1ac22",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_62865",
                    table="moderation_photosubmission",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="photosubmission",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "moderation_photosubmissionevent" ("caption", "claimed_at", "claimed_by_id", "content_type_id", "created_at", "date_taken", "handled_at", "handled_by_id", "id", "notes", "object_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "photo_id", "status", "updated_at", "user_id") VALUES (NEW."caption", NEW."claimed_at", NEW."claimed_by_id", NEW."content_type_id", NEW."created_at", NEW."date_taken", NEW."handled_at", NEW."handled_by_id", NEW."id", NEW."notes", NEW."object_id", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."photo_id", NEW."status", NEW."updated_at", NEW."user_id"); RETURN NULL;',
                    hash="82c7edd7b108f50aed0b6b06e44786617792171c",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_9c311",
                    table="moderation_photosubmission",
                    when="AFTER",
                ),
            ),
        ),
    ]
