# Generated by Django 5.2.5 on 2025-08-24 19:25

import django.contrib.gis.db.models.fields
import django.db.models.deletion
import pgtrigger.compiler
import pgtrigger.migrations
from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ("parks", "0006_remove_company_insert_insert_and_more"),
        ("pghistory", "0006_delete_aggregateevent"),
    ]

    operations = [
        migrations.CreateModel(
            name="CompanyHeadquartersEvent",
            fields=[
                ("pgh_id", models.AutoField(primary_key=True, serialize=False)),
                ("pgh_created_at", models.DateTimeField(auto_now_add=True)),
                ("pgh_label", models.TextField(help_text="The event label.")),
                ("id", models.BigIntegerField()),
                (
                    "street_address",
                    models.CharField(
                        blank=True,
                        help_text="Mailing address if publicly available",
                        max_length=255,
                    ),
                ),
                (
                    "city",
                    models.CharField(help_text="Headquarters city", max_length=100),
                ),
                (
                    "state_province",
                    models.CharField(blank=True, help_text="State/Province/Region", max_length=100),
                ),
                (
                    "country",
                    models.CharField(
                        default="USA",
                        help_text="Country where headquarters is located",
                        max_length=100,
                    ),
                ),
                (
                    "postal_code",
                    models.CharField(blank=True, help_text="ZIP or postal code", max_length=20),
                ),
                (
                    "mailing_address",
                    models.TextField(
                        blank=True,
                        help_text="Complete mailing address if different from basic address",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="ParkLocationEvent",
            fields=[
                ("pgh_id", models.AutoField(primary_key=True, serialize=False)),
                ("pgh_created_at", models.DateTimeField(auto_now_add=True)),
                ("pgh_label", models.TextField(help_text="The event label.")),
                ("id", models.BigIntegerField()),
                (
                    "point",
                    django.contrib.gis.db.models.fields.PointField(
                        blank=True,
                        help_text="Geographic coordinates (longitude, latitude)",
                        null=True,
                        srid=4326,
                    ),
                ),
                ("street_address", models.CharField(blank=True, max_length=255)),
                ("city", models.CharField(max_length=100)),
                ("state", models.CharField(max_length=100)),
                ("country", models.CharField(default="USA", max_length=100)),
                ("postal_code", models.CharField(blank=True, max_length=20)),
                ("highway_exit", models.CharField(blank=True, max_length=100)),
                ("parking_notes", models.TextField(blank=True)),
                ("best_arrival_time", models.TimeField(blank=True, null=True)),
                ("seasonal_notes", models.TextField(blank=True)),
                ("osm_id", models.BigIntegerField(blank=True, null=True)),
                (
                    "osm_type",
                    models.CharField(
                        blank=True,
                        help_text="Type of OpenStreetMap object (node, way, or relation)",
                        max_length=10,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="companyheadquarters",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "parks_companyheadquartersevent" ("city", "company_id", "country", "created_at", "id", "mailing_address", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "postal_code", "state_province", "street_address", "updated_at") VALUES (NEW."city", NEW."company_id", NEW."country", NEW."created_at", NEW."id", NEW."mailing_address", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."postal_code", NEW."state_province", NEW."street_address", NEW."updated_at"); RETURN NULL;',
                    hash="acf99673091ec3717f404fdccefd6e0cb228c82e",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_72259",
                    table="parks_companyheadquarters",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="companyheadquarters",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "parks_companyheadquartersevent" ("city", "company_id", "country", "created_at", "id", "mailing_address", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "postal_code", "state_province", "street_address", "updated_at") VALUES (NEW."city", NEW."company_id", NEW."country", NEW."created_at", NEW."id", NEW."mailing_address", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."postal_code", NEW."state_province", NEW."street_address", NEW."updated_at"); RETURN NULL;',
                    hash="bbbff3a1c9748d3ce1b2bf1b705d03ea40530c9b",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_c5392",
                    table="parks_companyheadquarters",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="parklocation",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "parks_parklocationevent" ("best_arrival_time", "city", "country", "highway_exit", "id", "osm_id", "osm_type", "park_id", "parking_notes", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "point", "postal_code", "seasonal_notes", "state", "street_address") VALUES (NEW."best_arrival_time", NEW."city", NEW."country", NEW."highway_exit", NEW."id", NEW."osm_id", NEW."osm_type", NEW."park_id", NEW."parking_notes", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."point", NEW."postal_code", NEW."seasonal_notes", NEW."state", NEW."street_address"); RETURN NULL;',
                    hash="fcc717a6f7408f959ac1f6406d4ba42b674e3c55",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_f8c53",
                    table="parks_parklocation",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="parklocation",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "parks_parklocationevent" ("best_arrival_time", "city", "country", "highway_exit", "id", "osm_id", "osm_type", "park_id", "parking_notes", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "point", "postal_code", "seasonal_notes", "state", "street_address") VALUES (NEW."best_arrival_time", NEW."city", NEW."country", NEW."highway_exit", NEW."id", NEW."osm_id", NEW."osm_type", NEW."park_id", NEW."parking_notes", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."point", NEW."postal_code", NEW."seasonal_notes", NEW."state", NEW."street_address"); RETURN NULL;',
                    hash="dedb3937ae968cc9f2b30309fbf72d9168039efe",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_6dd0d",
                    table="parks_parklocation",
                    when="AFTER",
                ),
            ),
        ),
        migrations.AddField(
            model_name="companyheadquartersevent",
            name="company",
            field=models.ForeignKey(
                db_constraint=False,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                related_query_name="+",
                to="parks.company",
            ),
        ),
        migrations.AddField(
            model_name="companyheadquartersevent",
            name="pgh_context",
            field=models.ForeignKey(
                db_constraint=False,
                null=True,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                to="pghistory.context",
            ),
        ),
        migrations.AddField(
            model_name="companyheadquartersevent",
            name="pgh_obj",
            field=models.ForeignKey(
                db_constraint=False,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="events",
                to="parks.companyheadquarters",
            ),
        ),
        migrations.AddField(
            model_name="parklocationevent",
            name="park",
            field=models.ForeignKey(
                db_constraint=False,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                related_query_name="+",
                to="parks.park",
            ),
        ),
        migrations.AddField(
            model_name="parklocationevent",
            name="pgh_context",
            field=models.ForeignKey(
                db_constraint=False,
                null=True,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                to="pghistory.context",
            ),
        ),
        migrations.AddField(
            model_name="parklocationevent",
            name="pgh_obj",
            field=models.ForeignKey(
                db_constraint=False,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="events",
                to="parks.parklocation",
            ),
        ),
    ]
