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

import django.contrib.gis.db.models.fields
import django.contrib.postgres.fields
import django.core.validators
import django.db.models.deletion
import pgtrigger.compiler
import pgtrigger.migrations
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("pghistory", "0006_delete_aggregateevent"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Company",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=255)),
                ("slug", models.SlugField(max_length=255, unique=True)),
                (
                    "roles",
                    django.contrib.postgres.fields.ArrayField(
                        base_field=models.CharField(
                            choices=[
                                ("MANUFACTURER", "Ride Manufacturer"),
                                ("DESIGNER", "Ride Designer"),
                                ("OPERATOR", "Park Operator"),
                                ("PROPERTY_OWNER", "Property Owner"),
                            ],
                            max_length=20,
                        ),
                        blank=True,
                        default=list,
                        size=None,
                    ),
                ),
                ("description", models.TextField(blank=True)),
                ("website", models.URLField(blank=True)),
                ("founded_date", models.DateField(blank=True, null=True)),
                ("rides_count", models.IntegerField(default=0)),
                ("coasters_count", models.IntegerField(default=0)),
            ],
            options={
                "verbose_name_plural": "Companies",
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="CompanyEvent",
            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()),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=255)),
                ("slug", models.SlugField(db_index=False, max_length=255)),
                (
                    "roles",
                    django.contrib.postgres.fields.ArrayField(
                        base_field=models.CharField(
                            choices=[
                                ("MANUFACTURER", "Ride Manufacturer"),
                                ("DESIGNER", "Ride Designer"),
                                ("OPERATOR", "Park Operator"),
                                ("PROPERTY_OWNER", "Property Owner"),
                            ],
                            max_length=20,
                        ),
                        blank=True,
                        default=list,
                        size=None,
                    ),
                ),
                ("description", models.TextField(blank=True)),
                ("website", models.URLField(blank=True)),
                ("founded_date", models.DateField(blank=True, null=True)),
                ("rides_count", models.IntegerField(default=0)),
                ("coasters_count", models.IntegerField(default=0)),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Ride",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=255)),
                ("slug", models.SlugField(max_length=255)),
                ("description", models.TextField(blank=True)),
                (
                    "category",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("", "Select ride type"),
                            ("RC", "Roller Coaster"),
                            ("DR", "Dark Ride"),
                            ("FR", "Flat Ride"),
                            ("WR", "Water Ride"),
                            ("TR", "Transport"),
                            ("OT", "Other"),
                        ],
                        default="",
                        max_length=2,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("", "Select status"),
                            ("OPERATING", "Operating"),
                            ("CLOSED_TEMP", "Temporarily Closed"),
                            ("SBNO", "Standing But Not Operating"),
                            ("CLOSING", "Closing"),
                            ("CLOSED_PERM", "Permanently Closed"),
                            ("UNDER_CONSTRUCTION", "Under Construction"),
                            ("DEMOLISHED", "Demolished"),
                            ("RELOCATED", "Relocated"),
                        ],
                        default="OPERATING",
                        max_length=20,
                    ),
                ),
                (
                    "post_closing_status",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("SBNO", "Standing But Not Operating"),
                            ("CLOSED_PERM", "Permanently Closed"),
                        ],
                        help_text="Status to change to after closing date",
                        max_length=20,
                        null=True,
                    ),
                ),
                ("opening_date", models.DateField(blank=True, null=True)),
                ("closing_date", models.DateField(blank=True, null=True)),
                ("status_since", models.DateField(blank=True, null=True)),
                (
                    "min_height_in",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "max_height_in",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "capacity_per_hour",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "ride_duration_seconds",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "average_rating",
                    models.DecimalField(blank=True, decimal_places=2, max_digits=3, null=True),
                ),
            ],
            options={
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="RideLocation",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "point",
                    django.contrib.gis.db.models.fields.PointField(
                        blank=True,
                        help_text="Geographic coordinates for ride location (longitude, latitude)",
                        null=True,
                        srid=4326,
                    ),
                ),
                (
                    "park_area",
                    models.CharField(
                        blank=True,
                        db_index=True,
                        help_text="Themed area or land within the park (e.g., 'Frontierland', 'Tomorrowland')",
                        max_length=100,
                    ),
                ),
                (
                    "notes",
                    models.TextField(blank=True, help_text="General location notes"),
                ),
                (
                    "entrance_notes",
                    models.TextField(
                        blank=True,
                        help_text="Directions to ride entrance, queue location, or navigation tips",
                    ),
                ),
                (
                    "accessibility_notes",
                    models.TextField(
                        blank=True,
                        help_text="Information about accessible entrances, wheelchair access, etc.",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "Ride Location",
                "verbose_name_plural": "Ride Locations",
                "ordering": ["ride__name"],
            },
        ),
        migrations.CreateModel(
            name="RideModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=255)),
                ("description", models.TextField(blank=True)),
                (
                    "category",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("", "Select ride type"),
                            ("RC", "Roller Coaster"),
                            ("DR", "Dark Ride"),
                            ("FR", "Flat Ride"),
                            ("WR", "Water Ride"),
                            ("TR", "Transport"),
                            ("OT", "Other"),
                        ],
                        default="",
                        max_length=2,
                    ),
                ),
            ],
            options={
                "ordering": ["manufacturer", "name"],
            },
        ),
        migrations.CreateModel(
            name="RideReview",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "rating",
                    models.PositiveSmallIntegerField(
                        validators=[
                            django.core.validators.MinValueValidator(1),
                            django.core.validators.MaxValueValidator(10),
                        ]
                    ),
                ),
                ("title", models.CharField(max_length=200)),
                ("content", models.TextField()),
                ("visit_date", models.DateField()),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("is_published", models.BooleanField(default=True)),
                ("moderation_notes", models.TextField(blank=True)),
                ("moderated_at", models.DateTimeField(blank=True, null=True)),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="RideReviewEvent",
            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()),
                (
                    "rating",
                    models.PositiveSmallIntegerField(
                        validators=[
                            django.core.validators.MinValueValidator(1),
                            django.core.validators.MaxValueValidator(10),
                        ]
                    ),
                ),
                ("title", models.CharField(max_length=200)),
                ("content", models.TextField()),
                ("visit_date", models.DateField()),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("is_published", models.BooleanField(default=True)),
                ("moderation_notes", models.TextField(blank=True)),
                ("moderated_at", models.DateTimeField(blank=True, null=True)),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="RollerCoasterStats",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "height_ft",
                    models.DecimalField(blank=True, decimal_places=2, max_digits=6, null=True),
                ),
                (
                    "length_ft",
                    models.DecimalField(blank=True, decimal_places=2, max_digits=7, null=True),
                ),
                (
                    "speed_mph",
                    models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True),
                ),
                ("inversions", models.PositiveIntegerField(default=0)),
                (
                    "ride_time_seconds",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                ("track_type", models.CharField(blank=True, max_length=255)),
                (
                    "track_material",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("STEEL", "Steel"),
                            ("WOOD", "Wood"),
                            ("HYBRID", "Hybrid"),
                        ],
                        default="STEEL",
                        max_length=20,
                    ),
                ),
                (
                    "roller_coaster_type",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("SITDOWN", "Sit Down"),
                            ("INVERTED", "Inverted"),
                            ("FLYING", "Flying"),
                            ("STANDUP", "Stand Up"),
                            ("WING", "Wing"),
                            ("DIVE", "Dive"),
                            ("FAMILY", "Family"),
                            ("WILD_MOUSE", "Wild Mouse"),
                            ("SPINNING", "Spinning"),
                            ("FOURTH_DIMENSION", "4th Dimension"),
                            ("OTHER", "Other"),
                        ],
                        default="SITDOWN",
                        max_length=20,
                    ),
                ),
                (
                    "max_drop_height_ft",
                    models.DecimalField(blank=True, decimal_places=2, max_digits=6, null=True),
                ),
                (
                    "launch_type",
                    models.CharField(
                        choices=[
                            ("CHAIN", "Chain Lift"),
                            ("LSM", "LSM Launch"),
                            ("HYDRAULIC", "Hydraulic Launch"),
                            ("GRAVITY", "Gravity"),
                            ("OTHER", "Other"),
                        ],
                        default="CHAIN",
                        max_length=20,
                    ),
                ),
                ("train_style", models.CharField(blank=True, max_length=255)),
                (
                    "trains_count",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "cars_per_train",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "seats_per_car",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
            ],
            options={
                "verbose_name": "Roller Coaster Statistics",
                "verbose_name_plural": "Roller Coaster Statistics",
            },
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="company",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "rides_companyevent" ("coasters_count", "created_at", "description", "founded_date", "id", "name", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "rides_count", "roles", "slug", "updated_at", "website") VALUES (NEW."coasters_count", NEW."created_at", NEW."description", NEW."founded_date", NEW."id", NEW."name", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."rides_count", NEW."roles", NEW."slug", NEW."updated_at", NEW."website"); RETURN NULL;',
                    hash="[AWS-SECRET-REMOVED]",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_e7194",
                    table="rides_company",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="company",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "rides_companyevent" ("coasters_count", "created_at", "description", "founded_date", "id", "name", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "rides_count", "roles", "slug", "updated_at", "website") VALUES (NEW."coasters_count", NEW."created_at", NEW."description", NEW."founded_date", NEW."id", NEW."name", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."rides_count", NEW."roles", NEW."slug", NEW."updated_at", NEW."website"); RETURN NULL;',
                    hash="[AWS-SECRET-REMOVED]",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_456a8",
                    table="rides_company",
                    when="AFTER",
                ),
            ),
        ),
        migrations.AddField(
            model_name="companyevent",
            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="companyevent",
            name="pgh_obj",
            field=models.ForeignKey(
                db_constraint=False,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="events",
                to="rides.company",
            ),
        ),
        migrations.AddField(
            model_name="ride",
            name="designer",
            field=models.ForeignKey(
                blank=True,
                limit_choices_to={"roles__contains": ["DESIGNER"]},
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="designed_rides",
                to="rides.company",
            ),
        ),
        migrations.AddField(
            model_name="ride",
            name="manufacturer",
            field=models.ForeignKey(
                blank=True,
                limit_choices_to={"roles__contains": ["MANUFACTURER"]},
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="manufactured_rides",
                to="rides.company",
            ),
        ),
        migrations.AddField(
            model_name="ride",
            name="park",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="rides",
                to="parks.park",
            ),
        ),
        migrations.AddField(
            model_name="ride",
            name="park_area",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="rides",
                to="parks.parkarea",
            ),
        ),
        migrations.AddField(
            model_name="ridelocation",
            name="ride",
            field=models.OneToOneField(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="ride_location",
                to="rides.ride",
            ),
        ),
        migrations.AddField(
            model_name="ridemodel",
            name="manufacturer",
            field=models.ForeignKey(
                blank=True,
                limit_choices_to={"roles__contains": ["MANUFACTURER"]},
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="ride_models",
                to="rides.company",
            ),
        ),
        migrations.AddField(
            model_name="ride",
            name="ride_model",
            field=models.ForeignKey(
                blank=True,
                help_text="The specific model/type of this ride",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="rides",
                to="rides.ridemodel",
            ),
        ),
        migrations.AddField(
            model_name="ridereview",
            name="moderated_by",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="moderated_ride_reviews",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="ridereview",
            name="ride",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="reviews",
                to="rides.ride",
            ),
        ),
        migrations.AddField(
            model_name="ridereview",
            name="user",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="ride_reviews",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="ridereviewevent",
            name="moderated_by",
            field=models.ForeignKey(
                blank=True,
                db_constraint=False,
                null=True,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                related_query_name="+",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="ridereviewevent",
            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="ridereviewevent",
            name="pgh_obj",
            field=models.ForeignKey(
                db_constraint=False,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="events",
                to="rides.ridereview",
            ),
        ),
        migrations.AddField(
            model_name="ridereviewevent",
            name="ride",
            field=models.ForeignKey(
                db_constraint=False,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                related_query_name="+",
                to="rides.ride",
            ),
        ),
        migrations.AddField(
            model_name="ridereviewevent",
            name="user",
            field=models.ForeignKey(
                db_constraint=False,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                related_query_name="+",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="rollercoasterstats",
            name="ride",
            field=models.OneToOneField(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="coaster_stats",
                to="rides.ride",
            ),
        ),
        migrations.AddIndex(
            model_name="ridelocation",
            index=models.Index(fields=["park_area"], name="rides_ridel_park_ar_26c90c_idx"),
        ),
        migrations.AlterUniqueTogether(
            name="ridemodel",
            unique_together={("manufacturer", "name")},
        ),
        migrations.AlterUniqueTogether(
            name="ride",
            unique_together={("park", "slug")},
        ),
        migrations.AlterUniqueTogether(
            name="ridereview",
            unique_together={("ride", "user")},
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="ridereview",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "rides_ridereviewevent" ("content", "created_at", "id", "is_published", "moderated_at", "moderated_by_id", "moderation_notes", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "rating", "ride_id", "title", "updated_at", "user_id", "visit_date") VALUES (NEW."content", NEW."created_at", NEW."id", NEW."is_published", NEW."moderated_at", NEW."moderated_by_id", NEW."moderation_notes", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."rating", NEW."ride_id", NEW."title", NEW."updated_at", NEW."user_id", NEW."visit_date"); RETURN NULL;',
                    hash="[AWS-SECRET-REMOVED]",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_33237",
                    table="rides_ridereview",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="ridereview",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "rides_ridereviewevent" ("content", "created_at", "id", "is_published", "moderated_at", "moderated_by_id", "moderation_notes", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "rating", "ride_id", "title", "updated_at", "user_id", "visit_date") VALUES (NEW."content", NEW."created_at", NEW."id", NEW."is_published", NEW."moderated_at", NEW."moderated_by_id", NEW."moderation_notes", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."rating", NEW."ride_id", NEW."title", NEW."updated_at", NEW."user_id", NEW."visit_date"); RETURN NULL;',
                    hash="[AWS-SECRET-REMOVED]",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_90298",
                    table="rides_ridereview",
                    when="AFTER",
                ),
            ),
        ),
    ]
