# Generated by Django 5.2.5 on 2025-08-30 21:41

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", "0004_alter_moderationqueue_options_and_more"),
    ]

    operations = [
        pgtrigger.migrations.RemoveTrigger(
            model_name="photosubmission",
            name="insert_insert",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="photosubmission",
            name="update_update",
        ),
        migrations.AlterField(
            model_name="photosubmission",
            name="photo",
            field=models.ForeignKey(
                help_text="Photo submission stored on Cloudflare Images",
                on_delete=django.db.models.deletion.CASCADE,
                to="django_cloudflareimages_toolkit.cloudflareimage",
            ),
        ),
        migrations.AlterField(
            model_name="photosubmissionevent",
            name="photo",
            field=models.ForeignKey(
                db_constraint=False,
                help_text="Photo submission stored on Cloudflare Images",
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                related_query_name="+",
                to="django_cloudflareimages_toolkit.cloudflareimage",
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="photosubmission",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "moderation_photosubmissionevent" ("caption", "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."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="198c1500ffe6dd50f9fc4bc7bbfbc1c392f1faa6",
                    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", "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."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="4757ec44aa21ca0567f894df0c2a5db7d39ec98f",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_9c311",
                    table="moderation_photosubmission",
                    when="AFTER",
                ),
            ),
        ),
    ]
