# Generated by Django 5.2.5 on 2025-09-14 19:01

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


class Migration(migrations.Migration):

    dependencies = [
        ("parks", "0013_remove_park_insert_insert_remove_park_update_update_and_more"),
    ]

    operations = [
        pgtrigger.migrations.RemoveTrigger(
            model_name="park",
            name="insert_insert",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="park",
            name="update_update",
        ),
        migrations.AddField(
            model_name="park",
            name="opening_year",
            field=models.IntegerField(
                blank=True,
                db_index=True,
                help_text="Year the park opened (computed from opening_date)",
                null=True,
            ),
        ),
        migrations.AddField(
            model_name="park",
            name="search_text",
            field=models.TextField(
                blank=True,
                db_index=True,
                help_text="Searchable text combining name, description, location, and operator",
            ),
        ),
        migrations.AddField(
            model_name="parkevent",
            name="opening_year",
            field=models.IntegerField(
                blank=True,
                help_text="Year the park opened (computed from opening_date)",
                null=True,
            ),
        ),
        migrations.AddField(
            model_name="parkevent",
            name="search_text",
            field=models.TextField(
                blank=True,
                help_text="Searchable text combining name, description, location, and operator",
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="park",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "parks_parkevent" ("average_rating", "banner_image_id", "card_image_id", "closing_date", "coaster_count", "created_at", "description", "id", "name", "opening_date", "opening_year", "operating_season", "operator_id", "park_type", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "property_owner_id", "ride_count", "search_text", "size_acres", "slug", "status", "updated_at", "url", "website") VALUES (NEW."average_rating", NEW."banner_image_id", NEW."card_image_id", NEW."closing_date", NEW."coaster_count", NEW."created_at", NEW."description", NEW."id", NEW."name", NEW."opening_date", NEW."opening_year", NEW."operating_season", NEW."operator_id", NEW."park_type", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."property_owner_id", NEW."ride_count", NEW."search_text", NEW."size_acres", NEW."slug", NEW."status", NEW."updated_at", NEW."url", NEW."website"); RETURN NULL;',
                    hash="39ac89dc193467b8b41f06ff15903f0a3e22f6b0",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_66883",
                    table="parks_park",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="park",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "parks_parkevent" ("average_rating", "banner_image_id", "card_image_id", "closing_date", "coaster_count", "created_at", "description", "id", "name", "opening_date", "opening_year", "operating_season", "operator_id", "park_type", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "property_owner_id", "ride_count", "search_text", "size_acres", "slug", "status", "updated_at", "url", "website") VALUES (NEW."average_rating", NEW."banner_image_id", NEW."card_image_id", NEW."closing_date", NEW."coaster_count", NEW."created_at", NEW."description", NEW."id", NEW."name", NEW."opening_date", NEW."opening_year", NEW."operating_season", NEW."operator_id", NEW."park_type", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."property_owner_id", NEW."ride_count", NEW."search_text", NEW."size_acres", NEW."slug", NEW."status", NEW."updated_at", NEW."url", NEW."website"); RETURN NULL;',
                    hash="af7925b4ef24b42c66b7795b9e0c6c8f510e597c",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_19f56",
                    table="parks_park",
                    when="AFTER",
                ),
            ),
        ),
    ]
