# 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"),
        ("rides", "0016_remove_ride_insert_insert_remove_ride_update_update_and_more"),
    ]

    operations = [
        pgtrigger.migrations.RemoveTrigger(
            model_name="ridemodelphoto",
            name="insert_insert",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="ridemodelphoto",
            name="update_update",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="ridephoto",
            name="insert_insert",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="ridephoto",
            name="update_update",
        ),
        migrations.AlterField(
            model_name="ridemodelphoto",
            name="image",
            field=models.ForeignKey(
                help_text="Photo of the ride model stored on Cloudflare Images",
                on_delete=django.db.models.deletion.CASCADE,
                to="django_cloudflareimages_toolkit.cloudflareimage",
            ),
        ),
        migrations.AlterField(
            model_name="ridemodelphotoevent",
            name="image",
            field=models.ForeignKey(
                db_constraint=False,
                help_text="Photo of the ride model stored on Cloudflare Images",
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                related_query_name="+",
                to="django_cloudflareimages_toolkit.cloudflareimage",
            ),
        ),
        migrations.AlterField(
            model_name="ridephoto",
            name="image",
            field=models.ForeignKey(
                help_text="Ride photo stored on Cloudflare Images",
                on_delete=django.db.models.deletion.CASCADE,
                to="django_cloudflareimages_toolkit.cloudflareimage",
            ),
        ),
        migrations.AlterField(
            model_name="ridephotoevent",
            name="image",
            field=models.ForeignKey(
                db_constraint=False,
                help_text="Ride photo 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="ridemodelphoto",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "rides_ridemodelphotoevent" ("alt_text", "caption", "copyright_info", "created_at", "id", "image_id", "is_primary", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "photo_type", "photographer", "ride_model_id", "source", "updated_at") VALUES (NEW."alt_text", NEW."caption", NEW."copyright_info", NEW."created_at", NEW."id", NEW."image_id", NEW."is_primary", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."photo_type", NEW."photographer", NEW."ride_model_id", NEW."source", NEW."updated_at"); RETURN NULL;',
                    hash="fa289c31e25da0c08740d9e9c4072f3e4df81c42",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_c5e58",
                    table="rides_ridemodelphoto",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="ridemodelphoto",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "rides_ridemodelphotoevent" ("alt_text", "caption", "copyright_info", "created_at", "id", "image_id", "is_primary", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "photo_type", "photographer", "ride_model_id", "source", "updated_at") VALUES (NEW."alt_text", NEW."caption", NEW."copyright_info", NEW."created_at", NEW."id", NEW."image_id", NEW."is_primary", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."photo_type", NEW."photographer", NEW."ride_model_id", NEW."source", NEW."updated_at"); RETURN NULL;',
                    hash="1ead1d3fd3dd553f585ae76aa6f3215314322ff4",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_3afcd",
                    table="rides_ridemodelphoto",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="ridephoto",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "rides_ridephotoevent" ("alt_text", "caption", "created_at", "date_taken", "id", "image_id", "is_approved", "is_primary", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "photo_type", "ride_id", "updated_at", "uploaded_by_id") VALUES (NEW."alt_text", NEW."caption", NEW."created_at", NEW."date_taken", NEW."id", NEW."image_id", NEW."is_approved", NEW."is_primary", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."photo_type", NEW."ride_id", NEW."updated_at", NEW."uploaded_by_id"); RETURN NULL;',
                    hash="51487ac871d9d90c75f695f106e5f1f43fdb00c6",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_0043a",
                    table="rides_ridephoto",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="ridephoto",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "rides_ridephotoevent" ("alt_text", "caption", "created_at", "date_taken", "id", "image_id", "is_approved", "is_primary", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "photo_type", "ride_id", "updated_at", "uploaded_by_id") VALUES (NEW."alt_text", NEW."caption", NEW."created_at", NEW."date_taken", NEW."id", NEW."image_id", NEW."is_approved", NEW."is_primary", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."photo_type", NEW."ride_id", NEW."updated_at", NEW."uploaded_by_id"); RETURN NULL;',
                    hash="6147489f087c144f887386548cba269ffc193094",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_93a7e",
                    table="rides_ridephoto",
                    when="AFTER",
                ),
            ),
        ),
    ]
