mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 23:11:13 -05:00
Refactor code structure and remove redundant changes
This commit is contained in:
846
django-backend/apps/entities/migrations/0001_initial.py
Normal file
846
django-backend/apps/entities/migrations/0001_initial.py
Normal file
@@ -0,0 +1,846 @@
|
||||
# Generated by Django 4.2.8 on 2025-11-08 16:41
|
||||
|
||||
import dirtyfields.dirtyfields
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
import django_lifecycle.mixins
|
||||
import model_utils.fields
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
("core", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="Company",
|
||||
fields=[
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"name",
|
||||
models.CharField(
|
||||
db_index=True,
|
||||
help_text="Official company name",
|
||||
max_length=255,
|
||||
unique=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"slug",
|
||||
models.SlugField(
|
||||
help_text="URL-friendly identifier", max_length=255, unique=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"description",
|
||||
models.TextField(
|
||||
blank=True, help_text="Company description and history"
|
||||
),
|
||||
),
|
||||
(
|
||||
"company_types",
|
||||
models.JSONField(
|
||||
default=list,
|
||||
help_text="List of company types (manufacturer, operator, etc.)",
|
||||
),
|
||||
),
|
||||
(
|
||||
"founded_date",
|
||||
models.DateField(
|
||||
blank=True, help_text="Company founding date", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"founded_date_precision",
|
||||
models.CharField(
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
default="day",
|
||||
help_text="Precision of founded date",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"closed_date",
|
||||
models.DateField(
|
||||
blank=True,
|
||||
help_text="Company closure date (if applicable)",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"closed_date_precision",
|
||||
models.CharField(
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
default="day",
|
||||
help_text="Precision of closed date",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"website",
|
||||
models.URLField(blank=True, help_text="Official company website"),
|
||||
),
|
||||
(
|
||||
"logo_image_id",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
help_text="CloudFlare image ID for company logo",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"logo_image_url",
|
||||
models.URLField(
|
||||
blank=True, help_text="CloudFlare image URL for company logo"
|
||||
),
|
||||
),
|
||||
(
|
||||
"park_count",
|
||||
models.IntegerField(
|
||||
default=0, help_text="Number of parks operated (for operators)"
|
||||
),
|
||||
),
|
||||
(
|
||||
"ride_count",
|
||||
models.IntegerField(
|
||||
default=0,
|
||||
help_text="Number of rides manufactured (for manufacturers)",
|
||||
),
|
||||
),
|
||||
(
|
||||
"location",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
help_text="Company headquarters location",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="companies",
|
||||
to="core.locality",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Company",
|
||||
"verbose_name_plural": "Companies",
|
||||
"ordering": ["name"],
|
||||
},
|
||||
bases=(
|
||||
dirtyfields.dirtyfields.DirtyFieldsMixin,
|
||||
django_lifecycle.mixins.LifecycleModelMixin,
|
||||
models.Model,
|
||||
),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Park",
|
||||
fields=[
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"name",
|
||||
models.CharField(
|
||||
db_index=True, help_text="Official park name", max_length=255
|
||||
),
|
||||
),
|
||||
(
|
||||
"slug",
|
||||
models.SlugField(
|
||||
help_text="URL-friendly identifier", max_length=255, unique=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"description",
|
||||
models.TextField(
|
||||
blank=True, help_text="Park description and history"
|
||||
),
|
||||
),
|
||||
(
|
||||
"park_type",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("theme_park", "Theme Park"),
|
||||
("amusement_park", "Amusement Park"),
|
||||
("water_park", "Water Park"),
|
||||
(
|
||||
"family_entertainment_center",
|
||||
"Family Entertainment Center",
|
||||
),
|
||||
("traveling_park", "Traveling Park"),
|
||||
("zoo", "Zoo"),
|
||||
("aquarium", "Aquarium"),
|
||||
],
|
||||
db_index=True,
|
||||
help_text="Type of park",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"status",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("operating", "Operating"),
|
||||
("closed", "Closed"),
|
||||
("sbno", "Standing But Not Operating"),
|
||||
("under_construction", "Under Construction"),
|
||||
("planned", "Planned"),
|
||||
],
|
||||
db_index=True,
|
||||
default="operating",
|
||||
help_text="Current operational status",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"opening_date",
|
||||
models.DateField(
|
||||
blank=True,
|
||||
db_index=True,
|
||||
help_text="Park opening date",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"opening_date_precision",
|
||||
models.CharField(
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
default="day",
|
||||
help_text="Precision of opening date",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"closing_date",
|
||||
models.DateField(
|
||||
blank=True, help_text="Park closing date (if closed)", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"closing_date_precision",
|
||||
models.CharField(
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
default="day",
|
||||
help_text="Precision of closing date",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"latitude",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=7,
|
||||
help_text="Latitude coordinate",
|
||||
max_digits=10,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"longitude",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=7,
|
||||
help_text="Longitude coordinate",
|
||||
max_digits=10,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"website",
|
||||
models.URLField(blank=True, help_text="Official park website"),
|
||||
),
|
||||
(
|
||||
"banner_image_id",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
help_text="CloudFlare image ID for park banner",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"banner_image_url",
|
||||
models.URLField(
|
||||
blank=True, help_text="CloudFlare image URL for park banner"
|
||||
),
|
||||
),
|
||||
(
|
||||
"logo_image_id",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
help_text="CloudFlare image ID for park logo",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"logo_image_url",
|
||||
models.URLField(
|
||||
blank=True, help_text="CloudFlare image URL for park logo"
|
||||
),
|
||||
),
|
||||
(
|
||||
"ride_count",
|
||||
models.IntegerField(default=0, help_text="Total number of rides"),
|
||||
),
|
||||
(
|
||||
"coaster_count",
|
||||
models.IntegerField(
|
||||
default=0, help_text="Number of roller coasters"
|
||||
),
|
||||
),
|
||||
(
|
||||
"custom_fields",
|
||||
models.JSONField(
|
||||
blank=True,
|
||||
default=dict,
|
||||
help_text="Additional park-specific data",
|
||||
),
|
||||
),
|
||||
(
|
||||
"location",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
help_text="Park location",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="parks",
|
||||
to="core.locality",
|
||||
),
|
||||
),
|
||||
(
|
||||
"operator",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
help_text="Current park operator",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="operated_parks",
|
||||
to="entities.company",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Park",
|
||||
"verbose_name_plural": "Parks",
|
||||
"ordering": ["name"],
|
||||
},
|
||||
bases=(
|
||||
dirtyfields.dirtyfields.DirtyFieldsMixin,
|
||||
django_lifecycle.mixins.LifecycleModelMixin,
|
||||
models.Model,
|
||||
),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="RideModel",
|
||||
fields=[
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"name",
|
||||
models.CharField(
|
||||
db_index=True,
|
||||
help_text="Model name (e.g., 'Inverted Coaster', 'Boomerang')",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"slug",
|
||||
models.SlugField(
|
||||
help_text="URL-friendly identifier", max_length=255, unique=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"description",
|
||||
models.TextField(
|
||||
blank=True, help_text="Model description and technical details"
|
||||
),
|
||||
),
|
||||
(
|
||||
"model_type",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("coaster_model", "Roller Coaster Model"),
|
||||
("flat_ride_model", "Flat Ride Model"),
|
||||
("water_ride_model", "Water Ride Model"),
|
||||
("dark_ride_model", "Dark Ride Model"),
|
||||
("transport_ride_model", "Transport Ride Model"),
|
||||
],
|
||||
db_index=True,
|
||||
help_text="Type of ride model",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"typical_height",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=1,
|
||||
help_text="Typical height in feet",
|
||||
max_digits=6,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"typical_speed",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=1,
|
||||
help_text="Typical speed in mph",
|
||||
max_digits=6,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"typical_capacity",
|
||||
models.IntegerField(
|
||||
blank=True, help_text="Typical hourly capacity", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"image_id",
|
||||
models.CharField(
|
||||
blank=True, help_text="CloudFlare image ID", max_length=255
|
||||
),
|
||||
),
|
||||
(
|
||||
"image_url",
|
||||
models.URLField(blank=True, help_text="CloudFlare image URL"),
|
||||
),
|
||||
(
|
||||
"installation_count",
|
||||
models.IntegerField(
|
||||
default=0, help_text="Number of installations worldwide"
|
||||
),
|
||||
),
|
||||
(
|
||||
"manufacturer",
|
||||
models.ForeignKey(
|
||||
help_text="Manufacturer of this ride model",
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="ride_models",
|
||||
to="entities.company",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Ride Model",
|
||||
"verbose_name_plural": "Ride Models",
|
||||
"ordering": ["manufacturer__name", "name"],
|
||||
},
|
||||
bases=(
|
||||
dirtyfields.dirtyfields.DirtyFieldsMixin,
|
||||
django_lifecycle.mixins.LifecycleModelMixin,
|
||||
models.Model,
|
||||
),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Ride",
|
||||
fields=[
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"name",
|
||||
models.CharField(
|
||||
db_index=True, help_text="Ride name", max_length=255
|
||||
),
|
||||
),
|
||||
(
|
||||
"slug",
|
||||
models.SlugField(
|
||||
help_text="URL-friendly identifier", max_length=255, unique=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"description",
|
||||
models.TextField(
|
||||
blank=True, help_text="Ride description and history"
|
||||
),
|
||||
),
|
||||
(
|
||||
"ride_category",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("roller_coaster", "Roller Coaster"),
|
||||
("flat_ride", "Flat Ride"),
|
||||
("water_ride", "Water Ride"),
|
||||
("dark_ride", "Dark Ride"),
|
||||
("transport_ride", "Transport Ride"),
|
||||
("other", "Other"),
|
||||
],
|
||||
db_index=True,
|
||||
help_text="Broad ride category",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"ride_type",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
db_index=True,
|
||||
help_text="Specific ride type (e.g., 'Inverted Coaster', 'Drop Tower')",
|
||||
max_length=100,
|
||||
),
|
||||
),
|
||||
(
|
||||
"is_coaster",
|
||||
models.BooleanField(
|
||||
db_index=True,
|
||||
default=False,
|
||||
help_text="Is this ride a roller coaster?",
|
||||
),
|
||||
),
|
||||
(
|
||||
"status",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("operating", "Operating"),
|
||||
("closed", "Closed"),
|
||||
("sbno", "Standing But Not Operating"),
|
||||
("relocated", "Relocated"),
|
||||
("under_construction", "Under Construction"),
|
||||
("planned", "Planned"),
|
||||
],
|
||||
db_index=True,
|
||||
default="operating",
|
||||
help_text="Current operational status",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"opening_date",
|
||||
models.DateField(
|
||||
blank=True,
|
||||
db_index=True,
|
||||
help_text="Ride opening date",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"opening_date_precision",
|
||||
models.CharField(
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
default="day",
|
||||
help_text="Precision of opening date",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"closing_date",
|
||||
models.DateField(
|
||||
blank=True, help_text="Ride closing date (if closed)", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"closing_date_precision",
|
||||
models.CharField(
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
default="day",
|
||||
help_text="Precision of closing date",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"height",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=1,
|
||||
help_text="Height in feet",
|
||||
max_digits=6,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"speed",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=1,
|
||||
help_text="Top speed in mph",
|
||||
max_digits=6,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"length",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=1,
|
||||
help_text="Track/ride length in feet",
|
||||
max_digits=8,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"duration",
|
||||
models.IntegerField(
|
||||
blank=True, help_text="Ride duration in seconds", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"inversions",
|
||||
models.IntegerField(
|
||||
blank=True,
|
||||
help_text="Number of inversions (for coasters)",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"capacity",
|
||||
models.IntegerField(
|
||||
blank=True,
|
||||
help_text="Hourly capacity (riders per hour)",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"image_id",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
help_text="CloudFlare image ID for main photo",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"image_url",
|
||||
models.URLField(
|
||||
blank=True, help_text="CloudFlare image URL for main photo"
|
||||
),
|
||||
),
|
||||
(
|
||||
"custom_fields",
|
||||
models.JSONField(
|
||||
blank=True,
|
||||
default=dict,
|
||||
help_text="Additional ride-specific data",
|
||||
),
|
||||
),
|
||||
(
|
||||
"manufacturer",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
help_text="Ride manufacturer",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="manufactured_rides",
|
||||
to="entities.company",
|
||||
),
|
||||
),
|
||||
(
|
||||
"model",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
help_text="Specific ride model",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="rides",
|
||||
to="entities.ridemodel",
|
||||
),
|
||||
),
|
||||
(
|
||||
"park",
|
||||
models.ForeignKey(
|
||||
help_text="Park where ride is located",
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="rides",
|
||||
to="entities.park",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Ride",
|
||||
"verbose_name_plural": "Rides",
|
||||
"ordering": ["park__name", "name"],
|
||||
},
|
||||
bases=(
|
||||
dirtyfields.dirtyfields.DirtyFieldsMixin,
|
||||
django_lifecycle.mixins.LifecycleModelMixin,
|
||||
models.Model,
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ridemodel",
|
||||
index=models.Index(
|
||||
fields=["manufacturer", "name"], name="entities_ri_manufac_1fe3c1_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ridemodel",
|
||||
index=models.Index(
|
||||
fields=["model_type"], name="entities_ri_model_t_610d23_idx"
|
||||
),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name="ridemodel",
|
||||
unique_together={("manufacturer", "name")},
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ride",
|
||||
index=models.Index(
|
||||
fields=["park", "name"], name="entities_ri_park_id_e73e3b_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ride",
|
||||
index=models.Index(fields=["slug"], name="entities_ri_slug_d2d6bb_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ride",
|
||||
index=models.Index(fields=["status"], name="entities_ri_status_b69114_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ride",
|
||||
index=models.Index(
|
||||
fields=["is_coaster"], name="entities_ri_is_coas_912a4d_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ride",
|
||||
index=models.Index(
|
||||
fields=["ride_category"], name="entities_ri_ride_ca_bc4554_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ride",
|
||||
index=models.Index(
|
||||
fields=["opening_date"], name="entities_ri_opening_c4fc53_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ride",
|
||||
index=models.Index(
|
||||
fields=["manufacturer"], name="entities_ri_manufac_0d9a25_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="park",
|
||||
index=models.Index(fields=["name"], name="entities_pa_name_f8a746_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="park",
|
||||
index=models.Index(fields=["slug"], name="entities_pa_slug_a21c73_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="park",
|
||||
index=models.Index(fields=["status"], name="entities_pa_status_805296_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="park",
|
||||
index=models.Index(
|
||||
fields=["park_type"], name="entities_pa_park_ty_8eba41_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="park",
|
||||
index=models.Index(
|
||||
fields=["opening_date"], name="entities_pa_opening_102a60_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="park",
|
||||
index=models.Index(
|
||||
fields=["location"], name="entities_pa_locatio_20a884_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="company",
|
||||
index=models.Index(fields=["name"], name="entities_co_name_d061e8_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="company",
|
||||
index=models.Index(fields=["slug"], name="entities_co_slug_00ae5c_idx"),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,35 @@
|
||||
# Generated by Django 4.2.8 on 2025-11-08 17:03
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("entities", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="park",
|
||||
name="latitude",
|
||||
field=models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=7,
|
||||
help_text="Latitude coordinate. Primary in local dev, use location_point in production.",
|
||||
max_digits=10,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="park",
|
||||
name="longitude",
|
||||
field=models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=7,
|
||||
help_text="Longitude coordinate. Primary in local dev, use location_point in production.",
|
||||
max_digits=10,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,141 @@
|
||||
# Generated migration for Phase 2 - GIN Index Optimization
|
||||
from django.db import migrations, connection
|
||||
from django.contrib.postgres.indexes import GinIndex
|
||||
from django.contrib.postgres.search import SearchVector
|
||||
|
||||
|
||||
def is_postgresql():
|
||||
"""Check if the database backend is PostgreSQL/PostGIS."""
|
||||
return 'postgis' in connection.vendor or 'postgresql' in connection.vendor
|
||||
|
||||
|
||||
def populate_search_vectors(apps, schema_editor):
|
||||
"""Populate search_vector fields for all existing records."""
|
||||
if not is_postgresql():
|
||||
return
|
||||
|
||||
# Get models
|
||||
Company = apps.get_model('entities', 'Company')
|
||||
RideModel = apps.get_model('entities', 'RideModel')
|
||||
Park = apps.get_model('entities', 'Park')
|
||||
Ride = apps.get_model('entities', 'Ride')
|
||||
|
||||
# Update Company search vectors
|
||||
Company.objects.update(
|
||||
search_vector=(
|
||||
SearchVector('name', weight='A') +
|
||||
SearchVector('description', weight='B')
|
||||
)
|
||||
)
|
||||
|
||||
# Update RideModel search vectors
|
||||
RideModel.objects.update(
|
||||
search_vector=(
|
||||
SearchVector('name', weight='A') +
|
||||
SearchVector('manufacturer__name', weight='A') +
|
||||
SearchVector('description', weight='B')
|
||||
)
|
||||
)
|
||||
|
||||
# Update Park search vectors
|
||||
Park.objects.update(
|
||||
search_vector=(
|
||||
SearchVector('name', weight='A') +
|
||||
SearchVector('description', weight='B')
|
||||
)
|
||||
)
|
||||
|
||||
# Update Ride search vectors
|
||||
Ride.objects.update(
|
||||
search_vector=(
|
||||
SearchVector('name', weight='A') +
|
||||
SearchVector('park__name', weight='A') +
|
||||
SearchVector('manufacturer__name', weight='B') +
|
||||
SearchVector('description', weight='B')
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def reverse_search_vectors(apps, schema_editor):
|
||||
"""Clear search_vector fields for all records."""
|
||||
if not is_postgresql():
|
||||
return
|
||||
|
||||
# Get models
|
||||
Company = apps.get_model('entities', 'Company')
|
||||
RideModel = apps.get_model('entities', 'RideModel')
|
||||
Park = apps.get_model('entities', 'Park')
|
||||
Ride = apps.get_model('entities', 'Ride')
|
||||
|
||||
# Clear all search vectors
|
||||
Company.objects.update(search_vector=None)
|
||||
RideModel.objects.update(search_vector=None)
|
||||
Park.objects.update(search_vector=None)
|
||||
Ride.objects.update(search_vector=None)
|
||||
|
||||
|
||||
def add_gin_indexes(apps, schema_editor):
|
||||
"""Add GIN indexes on search_vector fields (PostgreSQL only)."""
|
||||
if not is_postgresql():
|
||||
return
|
||||
|
||||
# Use raw SQL to add GIN indexes
|
||||
with schema_editor.connection.cursor() as cursor:
|
||||
cursor.execute("""
|
||||
CREATE INDEX IF NOT EXISTS entities_company_search_idx
|
||||
ON entities_company USING gin(search_vector);
|
||||
""")
|
||||
cursor.execute("""
|
||||
CREATE INDEX IF NOT EXISTS entities_ridemodel_search_idx
|
||||
ON entities_ridemodel USING gin(search_vector);
|
||||
""")
|
||||
cursor.execute("""
|
||||
CREATE INDEX IF NOT EXISTS entities_park_search_idx
|
||||
ON entities_park USING gin(search_vector);
|
||||
""")
|
||||
cursor.execute("""
|
||||
CREATE INDEX IF NOT EXISTS entities_ride_search_idx
|
||||
ON entities_ride USING gin(search_vector);
|
||||
""")
|
||||
|
||||
|
||||
def remove_gin_indexes(apps, schema_editor):
|
||||
"""Remove GIN indexes (PostgreSQL only)."""
|
||||
if not is_postgresql():
|
||||
return
|
||||
|
||||
# Use raw SQL to drop GIN indexes
|
||||
with schema_editor.connection.cursor() as cursor:
|
||||
cursor.execute("DROP INDEX IF EXISTS entities_company_search_idx;")
|
||||
cursor.execute("DROP INDEX IF EXISTS entities_ridemodel_search_idx;")
|
||||
cursor.execute("DROP INDEX IF EXISTS entities_park_search_idx;")
|
||||
cursor.execute("DROP INDEX IF EXISTS entities_ride_search_idx;")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
"""
|
||||
Phase 2 Migration: Add GIN indexes for search optimization.
|
||||
|
||||
This migration:
|
||||
1. Adds GIN indexes on search_vector fields for optimal full-text search
|
||||
2. Populates search vectors for all existing database records
|
||||
3. Is PostgreSQL-specific and safe for SQLite environments
|
||||
"""
|
||||
|
||||
dependencies = [
|
||||
('entities', '0002_alter_park_latitude_alter_park_longitude'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# First, populate search vectors for existing records
|
||||
migrations.RunPython(
|
||||
populate_search_vectors,
|
||||
reverse_search_vectors,
|
||||
),
|
||||
|
||||
# Add GIN indexes for each model's search_vector field
|
||||
migrations.RunPython(
|
||||
add_gin_indexes,
|
||||
remove_gin_indexes,
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,936 @@
|
||||
# Generated by Django 4.2.8 on 2025-11-08 21:37
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
import model_utils.fields
|
||||
import pgtrigger.compiler
|
||||
import pgtrigger.migrations
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("core", "0001_initial"),
|
||||
("pghistory", "0006_delete_aggregateevent"),
|
||||
("entities", "0003_add_search_vector_gin_indexes"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
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.")),
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4, editable=False, serialize=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"name",
|
||||
models.CharField(help_text="Official company name", max_length=255),
|
||||
),
|
||||
(
|
||||
"slug",
|
||||
models.SlugField(
|
||||
db_index=False,
|
||||
help_text="URL-friendly identifier",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"description",
|
||||
models.TextField(
|
||||
blank=True, help_text="Company description and history"
|
||||
),
|
||||
),
|
||||
(
|
||||
"company_types",
|
||||
models.JSONField(
|
||||
default=list,
|
||||
help_text="List of company types (manufacturer, operator, etc.)",
|
||||
),
|
||||
),
|
||||
(
|
||||
"founded_date",
|
||||
models.DateField(
|
||||
blank=True, help_text="Company founding date", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"founded_date_precision",
|
||||
models.CharField(
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
default="day",
|
||||
help_text="Precision of founded date",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"closed_date",
|
||||
models.DateField(
|
||||
blank=True,
|
||||
help_text="Company closure date (if applicable)",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"closed_date_precision",
|
||||
models.CharField(
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
default="day",
|
||||
help_text="Precision of closed date",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"website",
|
||||
models.URLField(blank=True, help_text="Official company website"),
|
||||
),
|
||||
(
|
||||
"logo_image_id",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
help_text="CloudFlare image ID for company logo",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"logo_image_url",
|
||||
models.URLField(
|
||||
blank=True, help_text="CloudFlare image URL for company logo"
|
||||
),
|
||||
),
|
||||
(
|
||||
"park_count",
|
||||
models.IntegerField(
|
||||
default=0, help_text="Number of parks operated (for operators)"
|
||||
),
|
||||
),
|
||||
(
|
||||
"ride_count",
|
||||
models.IntegerField(
|
||||
default=0,
|
||||
help_text="Number of rides manufactured (for manufacturers)",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"abstract": False,
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="ParkEvent",
|
||||
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.")),
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4, editable=False, serialize=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"name",
|
||||
models.CharField(help_text="Official park name", max_length=255),
|
||||
),
|
||||
(
|
||||
"slug",
|
||||
models.SlugField(
|
||||
db_index=False,
|
||||
help_text="URL-friendly identifier",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"description",
|
||||
models.TextField(
|
||||
blank=True, help_text="Park description and history"
|
||||
),
|
||||
),
|
||||
(
|
||||
"park_type",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("theme_park", "Theme Park"),
|
||||
("amusement_park", "Amusement Park"),
|
||||
("water_park", "Water Park"),
|
||||
(
|
||||
"family_entertainment_center",
|
||||
"Family Entertainment Center",
|
||||
),
|
||||
("traveling_park", "Traveling Park"),
|
||||
("zoo", "Zoo"),
|
||||
("aquarium", "Aquarium"),
|
||||
],
|
||||
help_text="Type of park",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"status",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("operating", "Operating"),
|
||||
("closed", "Closed"),
|
||||
("sbno", "Standing But Not Operating"),
|
||||
("under_construction", "Under Construction"),
|
||||
("planned", "Planned"),
|
||||
],
|
||||
default="operating",
|
||||
help_text="Current operational status",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"opening_date",
|
||||
models.DateField(
|
||||
blank=True, help_text="Park opening date", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"opening_date_precision",
|
||||
models.CharField(
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
default="day",
|
||||
help_text="Precision of opening date",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"closing_date",
|
||||
models.DateField(
|
||||
blank=True, help_text="Park closing date (if closed)", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"closing_date_precision",
|
||||
models.CharField(
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
default="day",
|
||||
help_text="Precision of closing date",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"latitude",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=7,
|
||||
help_text="Latitude coordinate. Primary in local dev, use location_point in production.",
|
||||
max_digits=10,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"longitude",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=7,
|
||||
help_text="Longitude coordinate. Primary in local dev, use location_point in production.",
|
||||
max_digits=10,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"website",
|
||||
models.URLField(blank=True, help_text="Official park website"),
|
||||
),
|
||||
(
|
||||
"banner_image_id",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
help_text="CloudFlare image ID for park banner",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"banner_image_url",
|
||||
models.URLField(
|
||||
blank=True, help_text="CloudFlare image URL for park banner"
|
||||
),
|
||||
),
|
||||
(
|
||||
"logo_image_id",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
help_text="CloudFlare image ID for park logo",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"logo_image_url",
|
||||
models.URLField(
|
||||
blank=True, help_text="CloudFlare image URL for park logo"
|
||||
),
|
||||
),
|
||||
(
|
||||
"ride_count",
|
||||
models.IntegerField(default=0, help_text="Total number of rides"),
|
||||
),
|
||||
(
|
||||
"coaster_count",
|
||||
models.IntegerField(
|
||||
default=0, help_text="Number of roller coasters"
|
||||
),
|
||||
),
|
||||
(
|
||||
"custom_fields",
|
||||
models.JSONField(
|
||||
blank=True,
|
||||
default=dict,
|
||||
help_text="Additional park-specific data",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"abstract": False,
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="RideEvent",
|
||||
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.")),
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4, editable=False, serialize=False
|
||||
),
|
||||
),
|
||||
("name", models.CharField(help_text="Ride name", max_length=255)),
|
||||
(
|
||||
"slug",
|
||||
models.SlugField(
|
||||
db_index=False,
|
||||
help_text="URL-friendly identifier",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"description",
|
||||
models.TextField(
|
||||
blank=True, help_text="Ride description and history"
|
||||
),
|
||||
),
|
||||
(
|
||||
"ride_category",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("roller_coaster", "Roller Coaster"),
|
||||
("flat_ride", "Flat Ride"),
|
||||
("water_ride", "Water Ride"),
|
||||
("dark_ride", "Dark Ride"),
|
||||
("transport_ride", "Transport Ride"),
|
||||
("other", "Other"),
|
||||
],
|
||||
help_text="Broad ride category",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"ride_type",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
help_text="Specific ride type (e.g., 'Inverted Coaster', 'Drop Tower')",
|
||||
max_length=100,
|
||||
),
|
||||
),
|
||||
(
|
||||
"is_coaster",
|
||||
models.BooleanField(
|
||||
default=False, help_text="Is this ride a roller coaster?"
|
||||
),
|
||||
),
|
||||
(
|
||||
"status",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("operating", "Operating"),
|
||||
("closed", "Closed"),
|
||||
("sbno", "Standing But Not Operating"),
|
||||
("relocated", "Relocated"),
|
||||
("under_construction", "Under Construction"),
|
||||
("planned", "Planned"),
|
||||
],
|
||||
default="operating",
|
||||
help_text="Current operational status",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"opening_date",
|
||||
models.DateField(
|
||||
blank=True, help_text="Ride opening date", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"opening_date_precision",
|
||||
models.CharField(
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
default="day",
|
||||
help_text="Precision of opening date",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"closing_date",
|
||||
models.DateField(
|
||||
blank=True, help_text="Ride closing date (if closed)", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"closing_date_precision",
|
||||
models.CharField(
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
default="day",
|
||||
help_text="Precision of closing date",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"height",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=1,
|
||||
help_text="Height in feet",
|
||||
max_digits=6,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"speed",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=1,
|
||||
help_text="Top speed in mph",
|
||||
max_digits=6,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"length",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=1,
|
||||
help_text="Track/ride length in feet",
|
||||
max_digits=8,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"duration",
|
||||
models.IntegerField(
|
||||
blank=True, help_text="Ride duration in seconds", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"inversions",
|
||||
models.IntegerField(
|
||||
blank=True,
|
||||
help_text="Number of inversions (for coasters)",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"capacity",
|
||||
models.IntegerField(
|
||||
blank=True,
|
||||
help_text="Hourly capacity (riders per hour)",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"image_id",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
help_text="CloudFlare image ID for main photo",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"image_url",
|
||||
models.URLField(
|
||||
blank=True, help_text="CloudFlare image URL for main photo"
|
||||
),
|
||||
),
|
||||
(
|
||||
"custom_fields",
|
||||
models.JSONField(
|
||||
blank=True,
|
||||
default=dict,
|
||||
help_text="Additional ride-specific data",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"abstract": False,
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="RideModelEvent",
|
||||
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.")),
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4, editable=False, serialize=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"name",
|
||||
models.CharField(
|
||||
help_text="Model name (e.g., 'Inverted Coaster', 'Boomerang')",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"slug",
|
||||
models.SlugField(
|
||||
db_index=False,
|
||||
help_text="URL-friendly identifier",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"description",
|
||||
models.TextField(
|
||||
blank=True, help_text="Model description and technical details"
|
||||
),
|
||||
),
|
||||
(
|
||||
"model_type",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("coaster_model", "Roller Coaster Model"),
|
||||
("flat_ride_model", "Flat Ride Model"),
|
||||
("water_ride_model", "Water Ride Model"),
|
||||
("dark_ride_model", "Dark Ride Model"),
|
||||
("transport_ride_model", "Transport Ride Model"),
|
||||
],
|
||||
help_text="Type of ride model",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"typical_height",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=1,
|
||||
help_text="Typical height in feet",
|
||||
max_digits=6,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"typical_speed",
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=1,
|
||||
help_text="Typical speed in mph",
|
||||
max_digits=6,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"typical_capacity",
|
||||
models.IntegerField(
|
||||
blank=True, help_text="Typical hourly capacity", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"image_id",
|
||||
models.CharField(
|
||||
blank=True, help_text="CloudFlare image ID", max_length=255
|
||||
),
|
||||
),
|
||||
(
|
||||
"image_url",
|
||||
models.URLField(blank=True, help_text="CloudFlare image URL"),
|
||||
),
|
||||
(
|
||||
"installation_count",
|
||||
models.IntegerField(
|
||||
default=0, help_text="Number of installations worldwide"
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"abstract": False,
|
||||
},
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="company",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="insert_insert",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
func='INSERT INTO "entities_companyevent" ("closed_date", "closed_date_precision", "company_types", "created", "description", "founded_date", "founded_date_precision", "id", "location_id", "logo_image_id", "logo_image_url", "modified", "name", "park_count", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "ride_count", "slug", "website") VALUES (NEW."closed_date", NEW."closed_date_precision", NEW."company_types", NEW."created", NEW."description", NEW."founded_date", NEW."founded_date_precision", NEW."id", NEW."location_id", NEW."logo_image_id", NEW."logo_image_url", NEW."modified", NEW."name", NEW."park_count", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."ride_count", NEW."slug", NEW."website"); RETURN NULL;',
|
||||
hash="891243f1479adc9ae67c894ec6824b89b7997086",
|
||||
operation="INSERT",
|
||||
pgid="pgtrigger_insert_insert_ed498",
|
||||
table="entities_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 "entities_companyevent" ("closed_date", "closed_date_precision", "company_types", "created", "description", "founded_date", "founded_date_precision", "id", "location_id", "logo_image_id", "logo_image_url", "modified", "name", "park_count", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "ride_count", "slug", "website") VALUES (NEW."closed_date", NEW."closed_date_precision", NEW."company_types", NEW."created", NEW."description", NEW."founded_date", NEW."founded_date_precision", NEW."id", NEW."location_id", NEW."logo_image_id", NEW."logo_image_url", NEW."modified", NEW."name", NEW."park_count", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."ride_count", NEW."slug", NEW."website"); RETURN NULL;',
|
||||
hash="5d0f3d8dbb199afd7474de393b075b8e72c481fd",
|
||||
operation="UPDATE",
|
||||
pgid="pgtrigger_update_update_2d89e",
|
||||
table="entities_company",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="park",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="insert_insert",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
func='INSERT INTO "entities_parkevent" ("banner_image_id", "banner_image_url", "closing_date", "closing_date_precision", "coaster_count", "created", "custom_fields", "description", "id", "latitude", "location_id", "logo_image_id", "logo_image_url", "longitude", "modified", "name", "opening_date", "opening_date_precision", "operator_id", "park_type", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "ride_count", "slug", "status", "website") VALUES (NEW."banner_image_id", NEW."banner_image_url", NEW."closing_date", NEW."closing_date_precision", NEW."coaster_count", NEW."created", NEW."custom_fields", NEW."description", NEW."id", NEW."latitude", NEW."location_id", NEW."logo_image_id", NEW."logo_image_url", NEW."longitude", NEW."modified", NEW."name", NEW."opening_date", NEW."opening_date_precision", NEW."operator_id", NEW."park_type", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."ride_count", NEW."slug", NEW."status", NEW."website"); RETURN NULL;',
|
||||
hash="e03ce2a0516ff75f1703a6ccf069ce931f3123bc",
|
||||
operation="INSERT",
|
||||
pgid="pgtrigger_insert_insert_a5515",
|
||||
table="entities_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 "entities_parkevent" ("banner_image_id", "banner_image_url", "closing_date", "closing_date_precision", "coaster_count", "created", "custom_fields", "description", "id", "latitude", "location_id", "logo_image_id", "logo_image_url", "longitude", "modified", "name", "opening_date", "opening_date_precision", "operator_id", "park_type", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "ride_count", "slug", "status", "website") VALUES (NEW."banner_image_id", NEW."banner_image_url", NEW."closing_date", NEW."closing_date_precision", NEW."coaster_count", NEW."created", NEW."custom_fields", NEW."description", NEW."id", NEW."latitude", NEW."location_id", NEW."logo_image_id", NEW."logo_image_url", NEW."longitude", NEW."modified", NEW."name", NEW."opening_date", NEW."opening_date_precision", NEW."operator_id", NEW."park_type", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."ride_count", NEW."slug", NEW."status", NEW."website"); RETURN NULL;',
|
||||
hash="0e01b4eac8ef56aeb039c870c7ac194d2615012e",
|
||||
operation="UPDATE",
|
||||
pgid="pgtrigger_update_update_b436a",
|
||||
table="entities_park",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="ride",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="insert_insert",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
func='INSERT INTO "entities_rideevent" ("capacity", "closing_date", "closing_date_precision", "created", "custom_fields", "description", "duration", "height", "id", "image_id", "image_url", "inversions", "is_coaster", "length", "manufacturer_id", "model_id", "modified", "name", "opening_date", "opening_date_precision", "park_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "ride_category", "ride_type", "slug", "speed", "status") VALUES (NEW."capacity", NEW."closing_date", NEW."closing_date_precision", NEW."created", NEW."custom_fields", NEW."description", NEW."duration", NEW."height", NEW."id", NEW."image_id", NEW."image_url", NEW."inversions", NEW."is_coaster", NEW."length", NEW."manufacturer_id", NEW."model_id", NEW."modified", NEW."name", NEW."opening_date", NEW."opening_date_precision", NEW."park_id", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."ride_category", NEW."ride_type", NEW."slug", NEW."speed", NEW."status"); RETURN NULL;',
|
||||
hash="02f95397d881bd95627424df1a144956d5f15f8d",
|
||||
operation="INSERT",
|
||||
pgid="pgtrigger_insert_insert_23173",
|
||||
table="entities_ride",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="ride",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="update_update",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
|
||||
func='INSERT INTO "entities_rideevent" ("capacity", "closing_date", "closing_date_precision", "created", "custom_fields", "description", "duration", "height", "id", "image_id", "image_url", "inversions", "is_coaster", "length", "manufacturer_id", "model_id", "modified", "name", "opening_date", "opening_date_precision", "park_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "ride_category", "ride_type", "slug", "speed", "status") VALUES (NEW."capacity", NEW."closing_date", NEW."closing_date_precision", NEW."created", NEW."custom_fields", NEW."description", NEW."duration", NEW."height", NEW."id", NEW."image_id", NEW."image_url", NEW."inversions", NEW."is_coaster", NEW."length", NEW."manufacturer_id", NEW."model_id", NEW."modified", NEW."name", NEW."opening_date", NEW."opening_date_precision", NEW."park_id", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."ride_category", NEW."ride_type", NEW."slug", NEW."speed", NEW."status"); RETURN NULL;',
|
||||
hash="9377ca0c44ec8e548254d371a95e9ff7a6eb8684",
|
||||
operation="UPDATE",
|
||||
pgid="pgtrigger_update_update_c2972",
|
||||
table="entities_ride",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="ridemodel",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="insert_insert",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
func='INSERT INTO "entities_ridemodelevent" ("created", "description", "id", "image_id", "image_url", "installation_count", "manufacturer_id", "model_type", "modified", "name", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "slug", "typical_capacity", "typical_height", "typical_speed") VALUES (NEW."created", NEW."description", NEW."id", NEW."image_id", NEW."image_url", NEW."installation_count", NEW."manufacturer_id", NEW."model_type", NEW."modified", NEW."name", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."slug", NEW."typical_capacity", NEW."typical_height", NEW."typical_speed"); RETURN NULL;',
|
||||
hash="580a9d8a429d5140bc6bf553d6e0f9c06b7a7dec",
|
||||
operation="INSERT",
|
||||
pgid="pgtrigger_insert_insert_04de6",
|
||||
table="entities_ridemodel",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="ridemodel",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="update_update",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
|
||||
func='INSERT INTO "entities_ridemodelevent" ("created", "description", "id", "image_id", "image_url", "installation_count", "manufacturer_id", "model_type", "modified", "name", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "slug", "typical_capacity", "typical_height", "typical_speed") VALUES (NEW."created", NEW."description", NEW."id", NEW."image_id", NEW."image_url", NEW."installation_count", NEW."manufacturer_id", NEW."model_type", NEW."modified", NEW."name", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."slug", NEW."typical_capacity", NEW."typical_height", NEW."typical_speed"); RETURN NULL;',
|
||||
hash="b7d6519a2c97e7b543494b67c4f25826439a02ef",
|
||||
operation="UPDATE",
|
||||
pgid="pgtrigger_update_update_a70fd",
|
||||
table="entities_ridemodel",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ridemodelevent",
|
||||
name="manufacturer",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
help_text="Manufacturer of this ride model",
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="entities.company",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ridemodelevent",
|
||||
name="pgh_context",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="pghistory.context",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ridemodelevent",
|
||||
name="pgh_obj",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="events",
|
||||
related_query_name="+",
|
||||
to="entities.ridemodel",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="rideevent",
|
||||
name="manufacturer",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
help_text="Ride manufacturer",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="entities.company",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="rideevent",
|
||||
name="model",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
help_text="Specific ride model",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="entities.ridemodel",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="rideevent",
|
||||
name="park",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
help_text="Park where ride is located",
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="entities.park",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="rideevent",
|
||||
name="pgh_context",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="pghistory.context",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="rideevent",
|
||||
name="pgh_obj",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="events",
|
||||
related_query_name="+",
|
||||
to="entities.ride",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="parkevent",
|
||||
name="location",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
help_text="Park location",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="core.locality",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="parkevent",
|
||||
name="operator",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
help_text="Current park operator",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="entities.company",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="parkevent",
|
||||
name="pgh_context",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="pghistory.context",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="parkevent",
|
||||
name="pgh_obj",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="events",
|
||||
related_query_name="+",
|
||||
to="entities.park",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="companyevent",
|
||||
name="location",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
help_text="Company headquarters location",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="core.locality",
|
||||
),
|
||||
),
|
||||
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="+",
|
||||
related_query_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",
|
||||
related_query_name="+",
|
||||
to="entities.company",
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,12 @@
|
||||
# Generated by Django 4.2.8 on 2025-11-09 03:26
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("entities", "0004_companyevent_parkevent_rideevent_ridemodelevent_and_more"),
|
||||
]
|
||||
|
||||
operations = []
|
||||
@@ -0,0 +1,12 @@
|
||||
# Generated by Django 4.2.8 on 2025-11-09 03:27
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("entities", "0005_migrate_company_types_to_m2m"),
|
||||
]
|
||||
|
||||
operations = []
|
||||
@@ -0,0 +1,542 @@
|
||||
# Generated by Django 4.2.8 on 2025-11-09 15:30
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
import django_lifecycle.mixins
|
||||
import model_utils.fields
|
||||
import pgtrigger.compiler
|
||||
import pgtrigger.migrations
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("pghistory", "0006_delete_aggregateevent"),
|
||||
("entities", "0006_migrate_company_types_to_m2m"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="CompanyType",
|
||||
fields=[
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"code",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("manufacturer", "Manufacturer"),
|
||||
("operator", "Operator"),
|
||||
("designer", "Designer"),
|
||||
("supplier", "Supplier"),
|
||||
("contractor", "Contractor"),
|
||||
],
|
||||
db_index=True,
|
||||
help_text="Unique code identifier for the company type",
|
||||
max_length=50,
|
||||
unique=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"name",
|
||||
models.CharField(
|
||||
help_text="Display name for the company type", max_length=100
|
||||
),
|
||||
),
|
||||
(
|
||||
"description",
|
||||
models.TextField(
|
||||
blank=True,
|
||||
help_text="Description of what this company type represents",
|
||||
),
|
||||
),
|
||||
(
|
||||
"company_count",
|
||||
models.IntegerField(
|
||||
default=0, help_text="Cached count of companies with this type"
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Company Type",
|
||||
"verbose_name_plural": "Company Types",
|
||||
"db_table": "company_types",
|
||||
"ordering": ["name"],
|
||||
},
|
||||
bases=(django_lifecycle.mixins.LifecycleModelMixin, models.Model),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="CompanyTypeEvent",
|
||||
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.")),
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4, editable=False, serialize=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"code",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("manufacturer", "Manufacturer"),
|
||||
("operator", "Operator"),
|
||||
("designer", "Designer"),
|
||||
("supplier", "Supplier"),
|
||||
("contractor", "Contractor"),
|
||||
],
|
||||
help_text="Unique code identifier for the company type",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"name",
|
||||
models.CharField(
|
||||
help_text="Display name for the company type", max_length=100
|
||||
),
|
||||
),
|
||||
(
|
||||
"description",
|
||||
models.TextField(
|
||||
blank=True,
|
||||
help_text="Description of what this company type represents",
|
||||
),
|
||||
),
|
||||
(
|
||||
"company_count",
|
||||
models.IntegerField(
|
||||
default=0, help_text="Cached count of companies with this type"
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"abstract": False,
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="RideNameHistory",
|
||||
fields=[
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"former_name",
|
||||
models.CharField(
|
||||
db_index=True,
|
||||
help_text="Previous name of the ride",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"from_year",
|
||||
models.IntegerField(
|
||||
blank=True,
|
||||
help_text="Year when this name started being used",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"to_year",
|
||||
models.IntegerField(
|
||||
blank=True,
|
||||
help_text="Year when this name stopped being used",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"date_changed",
|
||||
models.DateField(
|
||||
blank=True,
|
||||
help_text="Exact date when name was changed",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"date_changed_precision",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
help_text="Precision of date_changed field",
|
||||
max_length=20,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"reason",
|
||||
models.TextField(
|
||||
blank=True,
|
||||
help_text="Reason for name change (e.g., 'Rebranding', 'Sponsor change')",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"order_index",
|
||||
models.IntegerField(
|
||||
blank=True,
|
||||
db_index=True,
|
||||
help_text="Custom sort order for displaying name history",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Ride Name History",
|
||||
"verbose_name_plural": "Ride Name Histories",
|
||||
"ordering": ["ride", "-to_year", "-from_year", "order_index"],
|
||||
},
|
||||
bases=(django_lifecycle.mixins.LifecycleModelMixin, models.Model),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="RideNameHistoryEvent",
|
||||
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.")),
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4, editable=False, serialize=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"former_name",
|
||||
models.CharField(
|
||||
help_text="Previous name of the ride", max_length=255
|
||||
),
|
||||
),
|
||||
(
|
||||
"from_year",
|
||||
models.IntegerField(
|
||||
blank=True,
|
||||
help_text="Year when this name started being used",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"to_year",
|
||||
models.IntegerField(
|
||||
blank=True,
|
||||
help_text="Year when this name stopped being used",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"date_changed",
|
||||
models.DateField(
|
||||
blank=True,
|
||||
help_text="Exact date when name was changed",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"date_changed_precision",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
choices=[("year", "Year"), ("month", "Month"), ("day", "Day")],
|
||||
help_text="Precision of date_changed field",
|
||||
max_length=20,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"reason",
|
||||
models.TextField(
|
||||
blank=True,
|
||||
help_text="Reason for name change (e.g., 'Rebranding', 'Sponsor change')",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"order_index",
|
||||
models.IntegerField(
|
||||
blank=True,
|
||||
help_text="Custom sort order for displaying name history",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"abstract": False,
|
||||
},
|
||||
),
|
||||
pgtrigger.migrations.RemoveTrigger(
|
||||
model_name="company",
|
||||
name="insert_insert",
|
||||
),
|
||||
pgtrigger.migrations.RemoveTrigger(
|
||||
model_name="company",
|
||||
name="update_update",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="company",
|
||||
name="company_types",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="companyevent",
|
||||
name="company_types",
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="company",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="insert_insert",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
func='INSERT INTO "entities_companyevent" ("closed_date", "closed_date_precision", "created", "description", "founded_date", "founded_date_precision", "id", "location_id", "logo_image_id", "logo_image_url", "modified", "name", "park_count", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "ride_count", "slug", "website") VALUES (NEW."closed_date", NEW."closed_date_precision", NEW."created", NEW."description", NEW."founded_date", NEW."founded_date_precision", NEW."id", NEW."location_id", NEW."logo_image_id", NEW."logo_image_url", NEW."modified", NEW."name", NEW."park_count", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."ride_count", NEW."slug", NEW."website"); RETURN NULL;',
|
||||
hash="9d74e2f8c1fd5cb457d1deb6d8bb3b55f690df7a",
|
||||
operation="INSERT",
|
||||
pgid="pgtrigger_insert_insert_ed498",
|
||||
table="entities_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 "entities_companyevent" ("closed_date", "closed_date_precision", "created", "description", "founded_date", "founded_date_precision", "id", "location_id", "logo_image_id", "logo_image_url", "modified", "name", "park_count", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "ride_count", "slug", "website") VALUES (NEW."closed_date", NEW."closed_date_precision", NEW."created", NEW."description", NEW."founded_date", NEW."founded_date_precision", NEW."id", NEW."location_id", NEW."logo_image_id", NEW."logo_image_url", NEW."modified", NEW."name", NEW."park_count", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."ride_count", NEW."slug", NEW."website"); RETURN NULL;',
|
||||
hash="79dd6fed8d6bb8a54dfb0efb1433d93e2c732152",
|
||||
operation="UPDATE",
|
||||
pgid="pgtrigger_update_update_2d89e",
|
||||
table="entities_company",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ridenamehistoryevent",
|
||||
name="pgh_context",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="pghistory.context",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ridenamehistoryevent",
|
||||
name="pgh_obj",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="events",
|
||||
related_query_name="+",
|
||||
to="entities.ridenamehistory",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ridenamehistoryevent",
|
||||
name="ride",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
help_text="Ride this name history belongs to",
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="entities.ride",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ridenamehistory",
|
||||
name="ride",
|
||||
field=models.ForeignKey(
|
||||
help_text="Ride this name history belongs to",
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="name_history",
|
||||
to="entities.ride",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="companytypeevent",
|
||||
name="pgh_context",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="pghistory.context",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="companytypeevent",
|
||||
name="pgh_obj",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="events",
|
||||
related_query_name="+",
|
||||
to="entities.companytype",
|
||||
),
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="companytype",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="insert_insert",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
func='INSERT INTO "entities_companytypeevent" ("code", "company_count", "created", "description", "id", "modified", "name", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id") VALUES (NEW."code", NEW."company_count", NEW."created", NEW."description", NEW."id", NEW."modified", NEW."name", _pgh_attach_context(), NOW(), \'insert\', NEW."id"); RETURN NULL;',
|
||||
hash="37b8907c9141c73466db70e30a15281129bdb623",
|
||||
operation="INSERT",
|
||||
pgid="pgtrigger_insert_insert_c2d35",
|
||||
table="company_types",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="companytype",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="update_update",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
|
||||
func='INSERT INTO "entities_companytypeevent" ("code", "company_count", "created", "description", "id", "modified", "name", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id") VALUES (NEW."code", NEW."company_count", NEW."created", NEW."description", NEW."id", NEW."modified", NEW."name", _pgh_attach_context(), NOW(), \'update\', NEW."id"); RETURN NULL;',
|
||||
hash="4f168297493a54875233a39c57cb4abd2490c0c0",
|
||||
operation="UPDATE",
|
||||
pgid="pgtrigger_update_update_fc3b6",
|
||||
table="company_types",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="company",
|
||||
name="types",
|
||||
field=models.ManyToManyField(
|
||||
blank=True,
|
||||
help_text="Types of company (manufacturer, operator, etc.)",
|
||||
related_name="companies",
|
||||
to="entities.companytype",
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ridenamehistory",
|
||||
index=models.Index(
|
||||
fields=["ride", "from_year"], name="entities_ri_ride_id_648621_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ridenamehistory",
|
||||
index=models.Index(
|
||||
fields=["ride", "to_year"], name="entities_ri_ride_id_7cfa50_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="ridenamehistory",
|
||||
index=models.Index(
|
||||
fields=["former_name"], name="entities_ri_former__c3173a_idx"
|
||||
),
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="ridenamehistory",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="insert_insert",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
func='INSERT INTO "entities_ridenamehistoryevent" ("created", "date_changed", "date_changed_precision", "former_name", "from_year", "id", "modified", "order_index", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "reason", "ride_id", "to_year") VALUES (NEW."created", NEW."date_changed", NEW."date_changed_precision", NEW."former_name", NEW."from_year", NEW."id", NEW."modified", NEW."order_index", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."reason", NEW."ride_id", NEW."to_year"); RETURN NULL;',
|
||||
hash="bba7baecb40457a954159e0d62aa06dc8746fd0c",
|
||||
operation="INSERT",
|
||||
pgid="pgtrigger_insert_insert_dd590",
|
||||
table="entities_ridenamehistory",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="ridenamehistory",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="update_update",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
|
||||
func='INSERT INTO "entities_ridenamehistoryevent" ("created", "date_changed", "date_changed_precision", "former_name", "from_year", "id", "modified", "order_index", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "reason", "ride_id", "to_year") VALUES (NEW."created", NEW."date_changed", NEW."date_changed_precision", NEW."former_name", NEW."from_year", NEW."id", NEW."modified", NEW."order_index", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."reason", NEW."ride_id", NEW."to_year"); RETURN NULL;',
|
||||
hash="bcd9a1ba98897e9e2d89c2056b9922f09a69c447",
|
||||
operation="UPDATE",
|
||||
pgid="pgtrigger_update_update_73687",
|
||||
table="entities_ridenamehistory",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
]
|
||||
0
django-backend/apps/entities/migrations/__init__.py
Normal file
0
django-backend/apps/entities/migrations/__init__.py
Normal file
Reference in New Issue
Block a user