# Generated by Django 5.2.10 on 2026-01-12 23:00

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


class Migration(migrations.Migration):

    dependencies = [
        ("django_cloudflareimages_toolkit", "0001_initial"),
        ("moderation", "0010_moderationauditlog"),
    ]

    operations = [
        pgtrigger.migrations.RemoveTrigger(
            model_name="editsubmission",
            name="insert_insert",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="editsubmission",
            name="update_update",
        ),
        migrations.AddField(
            model_name="editsubmission",
            name="caption",
            field=models.CharField(blank=True, help_text="Photo caption", max_length=255),
        ),
        migrations.AddField(
            model_name="editsubmission",
            name="date_taken",
            field=models.DateField(blank=True, help_text="Date the photo was taken", null=True),
        ),
        migrations.AddField(
            model_name="editsubmission",
            name="photo",
            field=models.ForeignKey(
                blank=True,
                help_text="Photo for photo submissions",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to="django_cloudflareimages_toolkit.cloudflareimage",
            ),
        ),
        migrations.AddField(
            model_name="editsubmissionevent",
            name="caption",
            field=models.CharField(blank=True, help_text="Photo caption", max_length=255),
        ),
        migrations.AddField(
            model_name="editsubmissionevent",
            name="date_taken",
            field=models.DateField(blank=True, help_text="Date the photo was taken", null=True),
        ),
        migrations.AddField(
            model_name="editsubmissionevent",
            name="photo",
            field=models.ForeignKey(
                blank=True,
                db_constraint=False,
                help_text="Photo for photo submissions",
                null=True,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                related_query_name="+",
                to="django_cloudflareimages_toolkit.cloudflareimage",
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="editsubmission",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "moderation_editsubmissionevent" ("caption", "changes", "claimed_at", "claimed_by_id", "content_type_id", "created_at", "date_taken", "handled_at", "handled_by_id", "id", "moderator_changes", "notes", "object_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "photo_id", "reason", "source", "status", "submission_type", "updated_at", "user_id") VALUES (NEW."caption", NEW."changes", 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."moderator_changes", NEW."notes", NEW."object_id", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."photo_id", NEW."reason", NEW."source", NEW."status", NEW."submission_type", NEW."updated_at", NEW."user_id"); RETURN NULL;',
                    hash="e9aed25fe6389b113919e729543a9abe20d9f30c",
                    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" ("caption", "changes", "claimed_at", "claimed_by_id", "content_type_id", "created_at", "date_taken", "handled_at", "handled_by_id", "id", "moderator_changes", "notes", "object_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "photo_id", "reason", "source", "status", "submission_type", "updated_at", "user_id") VALUES (NEW."caption", NEW."changes", 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."moderator_changes", NEW."notes", NEW."object_id", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."photo_id", NEW."reason", NEW."source", NEW."status", NEW."submission_type", NEW."updated_at", NEW."user_id"); RETURN NULL;',
                    hash="070083ba4d2d459067d9c3a90356a759f6262a90",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_ab38f",
                    table="moderation_editsubmission",
                    when="AFTER",
                ),
            ),
        ),
    ]
