mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-21 17:11:08 -05:00
okay fine
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
# Generated by Django 5.1.2 on 2024-10-28 20:17
|
||||
|
||||
import django.db.models.deletion
|
||||
import simple_history.models
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@@ -12,57 +8,32 @@ class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('companies', '0001_initial'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='HistoricalPark',
|
||||
fields=[
|
||||
('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('slug', models.SlugField(max_length=255)),
|
||||
('location', models.CharField(max_length=255)),
|
||||
('description', models.TextField(blank=True)),
|
||||
('status', models.CharField(choices=[('OPERATING', 'Operating'), ('CLOSED_TEMP', 'Temporarily Closed'), ('CLOSED_PERM', 'Permanently Closed'), ('UNDER_CONSTRUCTION', 'Under Construction'), ('DEMOLISHED', 'Demolished')], default='OPERATING', max_length=20)),
|
||||
('opening_date', models.DateField(blank=True, null=True)),
|
||||
('closing_date', models.DateField(blank=True, null=True)),
|
||||
('operating_season', models.CharField(blank=True, max_length=255)),
|
||||
('size_acres', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)),
|
||||
('website', models.URLField(blank=True)),
|
||||
('average_rating', models.DecimalField(blank=True, decimal_places=2, max_digits=3, null=True)),
|
||||
('created_at', models.DateTimeField(blank=True, editable=False, null=True)),
|
||||
('updated_at', models.DateTimeField(blank=True, editable=False)),
|
||||
('history_id', models.AutoField(primary_key=True, serialize=False)),
|
||||
('history_date', models.DateTimeField(db_index=True)),
|
||||
('history_change_reason', models.CharField(max_length=100, null=True)),
|
||||
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
|
||||
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
|
||||
('owner', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='companies.company')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'historical park',
|
||||
'verbose_name_plural': 'historical parks',
|
||||
'ordering': ('-history_date', '-history_id'),
|
||||
'get_latest_by': ('history_date', 'history_id'),
|
||||
},
|
||||
bases=(simple_history.models.HistoricalChanges, models.Model),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Park',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('slug', models.SlugField(max_length=255, unique=True)),
|
||||
('location', models.CharField(max_length=255)),
|
||||
('description', models.TextField(blank=True)),
|
||||
('status', models.CharField(choices=[('OPERATING', 'Operating'), ('CLOSED_TEMP', 'Temporarily Closed'), ('CLOSED_PERM', 'Permanently Closed'), ('UNDER_CONSTRUCTION', 'Under Construction'), ('DEMOLISHED', 'Demolished')], default='OPERATING', max_length=20)),
|
||||
('status', models.CharField(choices=[('OPERATING', 'Operating'), ('CLOSED_TEMP', 'Temporarily Closed'), ('CLOSED_PERM', 'Permanently Closed'), ('UNDER_CONSTRUCTION', 'Under Construction'), ('DEMOLISHED', 'Demolished'), ('RELOCATED', 'Relocated')], default='OPERATING', max_length=20)),
|
||||
('opening_date', models.DateField(blank=True, null=True)),
|
||||
('closing_date', models.DateField(blank=True, null=True)),
|
||||
('operating_season', models.CharField(blank=True, max_length=255)),
|
||||
('size_acres', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)),
|
||||
('website', models.URLField(blank=True)),
|
||||
('average_rating', models.DecimalField(blank=True, decimal_places=2, max_digits=3, null=True)),
|
||||
('total_rides', models.IntegerField(blank=True, null=True)),
|
||||
('total_roller_coasters', models.IntegerField(blank=True, null=True)),
|
||||
('latitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
|
||||
('longitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
|
||||
('street_address', models.CharField(blank=True, max_length=255)),
|
||||
('city', models.CharField(blank=True, max_length=255)),
|
||||
('state', models.CharField(blank=True, max_length=255)),
|
||||
('country', models.CharField(blank=True, max_length=255)),
|
||||
('postal_code', models.CharField(blank=True, max_length=20)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True, null=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('owner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='parks', to='companies.company')),
|
||||
@@ -71,32 +42,6 @@ class Migration(migrations.Migration):
|
||||
'ordering': ['name'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='HistoricalParkArea',
|
||||
fields=[
|
||||
('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('slug', models.SlugField(max_length=255)),
|
||||
('description', models.TextField(blank=True)),
|
||||
('opening_date', models.DateField(blank=True, null=True)),
|
||||
('closing_date', models.DateField(blank=True, null=True)),
|
||||
('created_at', models.DateTimeField(blank=True, editable=False, null=True)),
|
||||
('updated_at', models.DateTimeField(blank=True, editable=False)),
|
||||
('history_id', models.AutoField(primary_key=True, serialize=False)),
|
||||
('history_date', models.DateTimeField(db_index=True)),
|
||||
('history_change_reason', models.CharField(max_length=100, null=True)),
|
||||
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
|
||||
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
|
||||
('park', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='parks.park')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'historical park area',
|
||||
'verbose_name_plural': 'historical park areas',
|
||||
'ordering': ('-history_date', '-history_id'),
|
||||
'get_latest_by': ('history_date', 'history_id'),
|
||||
},
|
||||
bases=(simple_history.models.HistoricalChanges, models.Model),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ParkArea',
|
||||
fields=[
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
# Generated manually
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('parks', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='park',
|
||||
name='country',
|
||||
field=models.CharField(max_length=2, default='US', help_text='Two-letter country code (ISO 3166-1 alpha-2)'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='historicalpark',
|
||||
name='country',
|
||||
field=models.CharField(max_length=2, default='US', help_text='Two-letter country code (ISO 3166-1 alpha-2)'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
84
parks/migrations/0002_historicalpark_historicalparkarea.py
Normal file
84
parks/migrations/0002_historicalpark_historicalparkarea.py
Normal file
@@ -0,0 +1,84 @@
|
||||
# Generated by Django 5.1.2 on 2024-11-03 03:44
|
||||
|
||||
import django.db.models.deletion
|
||||
import simple_history.models
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('companies', '0004_add_total_parks'),
|
||||
('parks', '0001_initial'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='HistoricalPark',
|
||||
fields=[
|
||||
('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('slug', models.SlugField(max_length=255)),
|
||||
('description', models.TextField(blank=True)),
|
||||
('status', models.CharField(choices=[('OPERATING', 'Operating'), ('CLOSED_TEMP', 'Temporarily Closed'), ('CLOSED_PERM', 'Permanently Closed'), ('UNDER_CONSTRUCTION', 'Under Construction'), ('DEMOLISHED', 'Demolished'), ('RELOCATED', 'Relocated')], default='OPERATING', max_length=20)),
|
||||
('opening_date', models.DateField(blank=True, null=True)),
|
||||
('closing_date', models.DateField(blank=True, null=True)),
|
||||
('operating_season', models.CharField(blank=True, max_length=255)),
|
||||
('size_acres', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)),
|
||||
('website', models.URLField(blank=True)),
|
||||
('average_rating', models.DecimalField(blank=True, decimal_places=2, max_digits=3, null=True)),
|
||||
('total_rides', models.IntegerField(blank=True, null=True)),
|
||||
('total_roller_coasters', models.IntegerField(blank=True, null=True)),
|
||||
('latitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
|
||||
('longitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
|
||||
('street_address', models.CharField(blank=True, max_length=255)),
|
||||
('city', models.CharField(blank=True, max_length=255)),
|
||||
('state', models.CharField(blank=True, max_length=255)),
|
||||
('country', models.CharField(blank=True, max_length=255)),
|
||||
('postal_code', models.CharField(blank=True, max_length=20)),
|
||||
('created_at', models.DateTimeField(blank=True, editable=False, null=True)),
|
||||
('updated_at', models.DateTimeField(blank=True, editable=False)),
|
||||
('history_id', models.AutoField(primary_key=True, serialize=False)),
|
||||
('history_date', models.DateTimeField(db_index=True)),
|
||||
('history_change_reason', models.CharField(max_length=100, null=True)),
|
||||
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
|
||||
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
|
||||
('owner', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='companies.company')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'historical park',
|
||||
'verbose_name_plural': 'historical parks',
|
||||
'ordering': ('-history_date', '-history_id'),
|
||||
'get_latest_by': ('history_date', 'history_id'),
|
||||
},
|
||||
bases=(simple_history.models.HistoricalChanges, models.Model),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='HistoricalParkArea',
|
||||
fields=[
|
||||
('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('slug', models.SlugField(max_length=255)),
|
||||
('description', models.TextField(blank=True)),
|
||||
('opening_date', models.DateField(blank=True, null=True)),
|
||||
('closing_date', models.DateField(blank=True, null=True)),
|
||||
('created_at', models.DateTimeField(blank=True, editable=False, null=True)),
|
||||
('updated_at', models.DateTimeField(blank=True, editable=False)),
|
||||
('history_id', models.AutoField(primary_key=True, serialize=False)),
|
||||
('history_date', models.DateTimeField(db_index=True)),
|
||||
('history_change_reason', models.CharField(max_length=100, null=True)),
|
||||
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
|
||||
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
|
||||
('park', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='parks.park')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'historical park area',
|
||||
'verbose_name_plural': 'historical park areas',
|
||||
'ordering': ('-history_date', '-history_id'),
|
||||
'get_latest_by': ('history_date', 'history_id'),
|
||||
},
|
||||
bases=(simple_history.models.HistoricalChanges, models.Model),
|
||||
),
|
||||
]
|
||||
@@ -1,45 +0,0 @@
|
||||
# Generated by Django 5.1.2 on 2024-10-30 01:20
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("parks", "0002_add_country_field"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="historicalpark",
|
||||
name="status",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
("OPERATING", "Operating"),
|
||||
("CLOSED_TEMP", "Temporarily Closed"),
|
||||
("CLOSED_PERM", "Permanently Closed"),
|
||||
("UNDER_CONSTRUCTION", "Under Construction"),
|
||||
("DEMOLISHED", "Demolished"),
|
||||
("RELOCATED", "Relocated"),
|
||||
],
|
||||
default="OPERATING",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="park",
|
||||
name="status",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
("OPERATING", "Operating"),
|
||||
("CLOSED_TEMP", "Temporarily Closed"),
|
||||
("CLOSED_PERM", "Permanently Closed"),
|
||||
("UNDER_CONSTRUCTION", "Under Construction"),
|
||||
("DEMOLISHED", "Demolished"),
|
||||
("RELOCATED", "Relocated"),
|
||||
],
|
||||
default="OPERATING",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
]
|
||||
55
parks/migrations/0003_update_coordinate_fields.py
Normal file
55
parks/migrations/0003_update_coordinate_fields.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('parks', '0002_historicalpark_historicalparkarea'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='park',
|
||||
name='latitude',
|
||||
field=models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=6,
|
||||
max_digits=9, # Changed to 9 to handle -90.000000 to 90.000000
|
||||
null=True,
|
||||
help_text='Latitude coordinate (-90 to 90)',
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='park',
|
||||
name='longitude',
|
||||
field=models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=6,
|
||||
max_digits=10, # Changed to 10 to handle -180.000000 to 180.000000
|
||||
null=True,
|
||||
help_text='Longitude coordinate (-180 to 180)',
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='latitude',
|
||||
field=models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=6,
|
||||
max_digits=9, # Changed to 9 to handle -90.000000 to 90.000000
|
||||
null=True,
|
||||
help_text='Latitude coordinate (-90 to 90)',
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='longitude',
|
||||
field=models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=6,
|
||||
max_digits=10, # Changed to 10 to handle -180.000000 to 180.000000
|
||||
null=True,
|
||||
help_text='Longitude coordinate (-180 to 180)',
|
||||
),
|
||||
),
|
||||
]
|
||||
101
parks/migrations/0004_add_coordinate_validators.py
Normal file
101
parks/migrations/0004_add_coordinate_validators.py
Normal file
@@ -0,0 +1,101 @@
|
||||
from django.db import migrations, models
|
||||
from django.core.validators import MinValueValidator, MaxValueValidator
|
||||
from decimal import Decimal
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
|
||||
def validate_coordinate_digits(value, max_digits):
|
||||
"""Validate total number of digits in a coordinate value"""
|
||||
if value is not None:
|
||||
# Convert to string and remove decimal point and sign
|
||||
str_val = str(abs(value)).replace('.', '')
|
||||
# Remove trailing zeros after decimal point
|
||||
str_val = str_val.rstrip('0')
|
||||
if len(str_val) > max_digits:
|
||||
raise ValidationError(
|
||||
f'Ensure that there are no more than {max_digits} digits in total.'
|
||||
)
|
||||
|
||||
|
||||
def validate_latitude_digits(value):
|
||||
"""Validate total number of digits in latitude"""
|
||||
validate_coordinate_digits(value, 9)
|
||||
|
||||
|
||||
def validate_longitude_digits(value):
|
||||
"""Validate total number of digits in longitude"""
|
||||
validate_coordinate_digits(value, 10)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('parks', '0003_update_coordinate_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='park',
|
||||
name='latitude',
|
||||
field=models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=6,
|
||||
help_text='Latitude coordinate (-90 to 90)',
|
||||
max_digits=9,
|
||||
null=True,
|
||||
validators=[
|
||||
MinValueValidator(Decimal('-90')),
|
||||
MaxValueValidator(Decimal('90')),
|
||||
validate_latitude_digits,
|
||||
],
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='park',
|
||||
name='longitude',
|
||||
field=models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=6,
|
||||
help_text='Longitude coordinate (-180 to 180)',
|
||||
max_digits=10,
|
||||
null=True,
|
||||
validators=[
|
||||
MinValueValidator(Decimal('-180')),
|
||||
MaxValueValidator(Decimal('180')),
|
||||
validate_longitude_digits,
|
||||
],
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='latitude',
|
||||
field=models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=6,
|
||||
help_text='Latitude coordinate (-90 to 90)',
|
||||
max_digits=9,
|
||||
null=True,
|
||||
validators=[
|
||||
MinValueValidator(Decimal('-90')),
|
||||
MaxValueValidator(Decimal('90')),
|
||||
validate_latitude_digits,
|
||||
],
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='longitude',
|
||||
field=models.DecimalField(
|
||||
blank=True,
|
||||
decimal_places=6,
|
||||
help_text='Longitude coordinate (-180 to 180)',
|
||||
max_digits=10,
|
||||
null=True,
|
||||
validators=[
|
||||
MinValueValidator(Decimal('-180')),
|
||||
MaxValueValidator(Decimal('180')),
|
||||
validate_longitude_digits,
|
||||
],
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -1,37 +0,0 @@
|
||||
# Generated by Django 5.1.2 on 2024-10-30 23:15
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("parks", "0003_alter_historicalpark_status_alter_park_status"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="historicalpark",
|
||||
name="city",
|
||||
field=models.CharField(blank=True, max_length=255),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="historicalpark",
|
||||
name="state",
|
||||
field=models.CharField(
|
||||
blank=True, help_text="State/Province/Region", max_length=255
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="park",
|
||||
name="city",
|
||||
field=models.CharField(blank=True, max_length=255),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="park",
|
||||
name="state",
|
||||
field=models.CharField(
|
||||
blank=True, help_text="State/Province/Region", max_length=255
|
||||
),
|
||||
),
|
||||
]
|
||||
58
parks/migrations/0005_normalize_coordinates.py
Normal file
58
parks/migrations/0005_normalize_coordinates.py
Normal file
@@ -0,0 +1,58 @@
|
||||
from django.db import migrations
|
||||
from decimal import Decimal, ROUND_DOWN
|
||||
|
||||
|
||||
def normalize_coordinate(value, max_digits, decimal_places):
|
||||
"""Normalize coordinate to have exactly 6 decimal places"""
|
||||
try:
|
||||
if value is None:
|
||||
return None
|
||||
|
||||
# Convert to Decimal for precise handling
|
||||
value = Decimal(str(value))
|
||||
# Round to exactly 6 decimal places
|
||||
value = value.quantize(Decimal('0.000001'), rounding=ROUND_DOWN)
|
||||
|
||||
return value
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
def normalize_existing_coordinates(apps, schema_editor):
|
||||
Park = apps.get_model('parks', 'Park')
|
||||
HistoricalPark = apps.get_model('parks', 'HistoricalPark')
|
||||
|
||||
# Normalize coordinates in current parks
|
||||
for park in Park.objects.all():
|
||||
if park.latitude is not None:
|
||||
park.latitude = normalize_coordinate(park.latitude, 9, 6)
|
||||
if park.longitude is not None:
|
||||
park.longitude = normalize_coordinate(park.longitude, 10, 6)
|
||||
park.save()
|
||||
|
||||
# Normalize coordinates in historical records
|
||||
for record in HistoricalPark.objects.all():
|
||||
if record.latitude is not None:
|
||||
record.latitude = normalize_coordinate(record.latitude, 9, 6)
|
||||
if record.longitude is not None:
|
||||
record.longitude = normalize_coordinate(record.longitude, 10, 6)
|
||||
record.save()
|
||||
|
||||
|
||||
def reverse_normalize_coordinates(apps, schema_editor):
|
||||
# No need to reverse normalization as it would only reduce precision
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('parks', '0004_add_coordinate_validators'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
normalize_existing_coordinates,
|
||||
reverse_normalize_coordinates
|
||||
),
|
||||
]
|
||||
@@ -1,23 +0,0 @@
|
||||
# Generated by Django 5.1.2 on 2024-10-30 23:46
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("parks", "0004_historicalpark_city_historicalpark_state_park_city_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="historicalpark",
|
||||
name="country",
|
||||
field=models.CharField(help_text="Country name", max_length=255),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="park",
|
||||
name="country",
|
||||
field=models.CharField(help_text="Country name", max_length=255),
|
||||
),
|
||||
]
|
||||
@@ -1,125 +0,0 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
def forwards_func(apps, schema_editor):
|
||||
# Get the historical models
|
||||
Park = apps.get_model("parks", "Park")
|
||||
Country = apps.get_model("cities_light", "Country")
|
||||
Region = apps.get_model("cities_light", "Region")
|
||||
City = apps.get_model("cities_light", "City")
|
||||
|
||||
# Create default country for existing parks
|
||||
default_country, _ = Country.objects.get_or_create(
|
||||
name='Unknown',
|
||||
name_ascii='Unknown',
|
||||
slug='unknown',
|
||||
code2='XX'
|
||||
)
|
||||
|
||||
# Store old values
|
||||
parks_data = []
|
||||
for park in Park.objects.all():
|
||||
parks_data.append({
|
||||
'id': park.id,
|
||||
'old_country': park.country,
|
||||
'old_state': park.state,
|
||||
'location': park.location
|
||||
})
|
||||
|
||||
# Remove old fields first
|
||||
Park._meta.get_field('country').null = True
|
||||
Park._meta.get_field('state').null = True
|
||||
Park.objects.all().update(country=None, state=None)
|
||||
|
||||
# Now update with new values
|
||||
for data in parks_data:
|
||||
park = Park.objects.get(id=data['id'])
|
||||
park.country_id = default_country.id
|
||||
park.save()
|
||||
|
||||
def reverse_func(apps, schema_editor):
|
||||
pass
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cities_light', '0011_alter_city_country_alter_city_region_and_more'),
|
||||
('parks', '0005_update_country_field_length'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# First make the fields nullable
|
||||
migrations.AlterField(
|
||||
model_name='park',
|
||||
name='country',
|
||||
field=models.CharField(max_length=255, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='country',
|
||||
field=models.CharField(max_length=255, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='park',
|
||||
name='state',
|
||||
field=models.CharField(max_length=255, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='state',
|
||||
field=models.CharField(max_length=255, null=True),
|
||||
),
|
||||
|
||||
# Run the data migration
|
||||
migrations.RunPython(forwards_func, reverse_func),
|
||||
|
||||
# Remove old fields
|
||||
migrations.RemoveField(
|
||||
model_name='park',
|
||||
name='state',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='historicalpark',
|
||||
name='state',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='park',
|
||||
name='country',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='historicalpark',
|
||||
name='country',
|
||||
),
|
||||
|
||||
# Add new fields
|
||||
migrations.AddField(
|
||||
model_name='park',
|
||||
name='country',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='cities_light.country'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='park',
|
||||
name='region',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='cities_light.region'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='park',
|
||||
name='city',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='cities_light.city'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='historicalpark',
|
||||
name='country',
|
||||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='cities_light.country'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='historicalpark',
|
||||
name='region',
|
||||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='cities_light.region'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='historicalpark',
|
||||
name='city',
|
||||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='cities_light.city'),
|
||||
),
|
||||
]
|
||||
@@ -1,17 +0,0 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cities_light', '0001_initial'),
|
||||
('parks', '0006_update_location_fields_to_cities_light'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='city',
|
||||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='cities_light.city'),
|
||||
),
|
||||
]
|
||||
@@ -1,43 +0,0 @@
|
||||
from django.db import migrations
|
||||
from django.db.models import Q
|
||||
|
||||
def fix_historical_park_data(apps, schema_editor):
|
||||
HistoricalPark = apps.get_model('parks', 'HistoricalPark')
|
||||
Park = apps.get_model('parks', 'Park')
|
||||
Country = apps.get_model('cities_light', 'Country')
|
||||
|
||||
# Get a default country (create one if none exists)
|
||||
default_country = Country.objects.first()
|
||||
if not default_country:
|
||||
default_country = Country.objects.create(name='Unknown')
|
||||
|
||||
# Fix all historical records with null country
|
||||
historical_records = HistoricalPark.objects.filter(
|
||||
Q(country__isnull=True) | Q(location__isnull=True)
|
||||
)
|
||||
|
||||
for record in historical_records:
|
||||
try:
|
||||
# Try to get the current park's country
|
||||
park = Park.objects.get(id=record.id)
|
||||
record.country = park.country
|
||||
record.location = park.location or f"{park.country.name}"
|
||||
except Park.DoesNotExist:
|
||||
# If park doesn't exist, use default country
|
||||
record.country = default_country
|
||||
record.location = default_country.name
|
||||
|
||||
record.save()
|
||||
|
||||
def reverse_func(apps, schema_editor):
|
||||
pass
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('parks', '0007_fix_historical_park_city_null'),
|
||||
('cities_light', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(fix_historical_park_data, reverse_func),
|
||||
]
|
||||
@@ -1,33 +0,0 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cities_light', '0001_initial'),
|
||||
('parks', '0008_fix_historical_park_data'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='city',
|
||||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='cities_light.city'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='region',
|
||||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='cities_light.region'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='location',
|
||||
field=models.CharField(max_length=255, default=''),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='country',
|
||||
field=models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='cities_light.country'),
|
||||
),
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Generated by Django 5.1.2 on 2024-10-31 20:15
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("cities_light", "0011_alter_city_country_alter_city_region_and_more"),
|
||||
("parks", "0009_fix_historical_park_fields"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="historicalpark",
|
||||
name="country",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
to="cities_light.country",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="park",
|
||||
name="country",
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.PROTECT, to="cities_light.country"
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -1,72 +0,0 @@
|
||||
from django.db import migrations, models
|
||||
from django.db.models import Q
|
||||
import django.db.models.deletion
|
||||
|
||||
def fix_historical_records(apps, schema_editor):
|
||||
HistoricalPark = apps.get_model('parks', 'HistoricalPark')
|
||||
Park = apps.get_model('parks', 'Park')
|
||||
Country = apps.get_model('cities_light', 'Country')
|
||||
|
||||
# Get or create a default country
|
||||
default_country = Country.objects.first()
|
||||
if not default_country:
|
||||
default_country = Country.objects.create(name='Unknown')
|
||||
|
||||
# Update all historical records with null values
|
||||
for record in HistoricalPark.objects.filter(Q(country__isnull=True) | Q(location__isnull=True)):
|
||||
try:
|
||||
park = Park.objects.get(id=record.id)
|
||||
record.country = park.country
|
||||
record.location = park.location
|
||||
except Park.DoesNotExist:
|
||||
record.country = default_country
|
||||
record.location = default_country.name
|
||||
record.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
atomic = False # Allow long-running operations
|
||||
|
||||
dependencies = [
|
||||
('parks', '0009_fix_historical_park_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# First, make sure all fields allow null temporarily
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='country',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name='+',
|
||||
to='cities_light.country'
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='location',
|
||||
field=models.CharField(max_length=255, null=True, blank=True),
|
||||
),
|
||||
|
||||
# Fix the data
|
||||
migrations.RunPython(fix_historical_records),
|
||||
|
||||
# Now make the fields non-nullable
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='country',
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name='+',
|
||||
to='cities_light.country'
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='location',
|
||||
field=models.CharField(max_length=255),
|
||||
),
|
||||
]
|
||||
@@ -1,52 +0,0 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('cities_light', '0001_initial'),
|
||||
('parks', '0010_fix_historical_records'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='city',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name='+',
|
||||
to='cities_light.city'
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='region',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name='+',
|
||||
to='cities_light.region'
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='country',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name='+',
|
||||
to='cities_light.country'
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='location',
|
||||
field=models.CharField(max_length=255, blank=True, null=True),
|
||||
),
|
||||
]
|
||||
@@ -1,13 +0,0 @@
|
||||
# Generated by Django 5.1.2 on 2024-10-31 20:17
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("parks", "0010_alter_historicalpark_country_alter_park_country"),
|
||||
("parks", "0010_fix_historical_records"),
|
||||
]
|
||||
|
||||
operations = []
|
||||
@@ -1,13 +0,0 @@
|
||||
# Generated by Django 5.1.2 on 2024-10-31 20:35
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("parks", "0011_alter_historicalpark_fields"),
|
||||
("parks", "0011_merge_20241031_1617"),
|
||||
]
|
||||
|
||||
operations = []
|
||||
@@ -1,67 +0,0 @@
|
||||
from django.db import migrations
|
||||
|
||||
def fix_null_locations(apps, schema_editor):
|
||||
Park = apps.get_model('parks', 'Park')
|
||||
Country = apps.get_model('cities_light', 'Country')
|
||||
Region = apps.get_model('cities_light', 'Region')
|
||||
City = apps.get_model('cities_light', 'City')
|
||||
|
||||
# Get or create default locations
|
||||
default_country = Country.objects.first()
|
||||
if not default_country:
|
||||
default_country = Country.objects.create(
|
||||
name='Unknown',
|
||||
name_ascii='Unknown',
|
||||
slug='unknown',
|
||||
geoname_id=0,
|
||||
alternate_names='',
|
||||
search_names='Unknown'
|
||||
)
|
||||
|
||||
default_region = Region.objects.filter(country=default_country).first()
|
||||
if not default_region:
|
||||
default_region = Region.objects.create(
|
||||
name='Unknown',
|
||||
name_ascii='Unknown',
|
||||
slug='unknown',
|
||||
geoname_id=0,
|
||||
alternate_names='',
|
||||
country=default_country,
|
||||
display_name='Unknown',
|
||||
search_names='Unknown'
|
||||
)
|
||||
|
||||
default_city = City.objects.filter(region=default_region).first()
|
||||
if not default_city:
|
||||
default_city = City.objects.create(
|
||||
name='Unknown',
|
||||
name_ascii='Unknown',
|
||||
slug='unknown',
|
||||
geoname_id=0,
|
||||
alternate_names='',
|
||||
region=default_region,
|
||||
country=default_country,
|
||||
display_name='Unknown',
|
||||
search_names='Unknown',
|
||||
latitude=0,
|
||||
longitude=0,
|
||||
population=0
|
||||
)
|
||||
|
||||
# Update parks with null locations
|
||||
for park in Park.objects.filter(country__isnull=True):
|
||||
park.country = default_country
|
||||
park.region = default_region
|
||||
park.city = default_city
|
||||
park.location = 'Unknown, Unknown, Unknown'
|
||||
park.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('parks', '0012_merge_20241031_1635'),
|
||||
('cities_light', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(fix_null_locations, reverse_code=migrations.RunPython.noop),
|
||||
]
|
||||
@@ -1,52 +0,0 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('cities_light', '0001_initial'),
|
||||
('parks', '0013_fix_null_locations'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='city',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name='+',
|
||||
to='cities_light.city'
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='region',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name='+',
|
||||
to='cities_light.region'
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='country',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name='+',
|
||||
to='cities_light.country'
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='location',
|
||||
field=models.CharField(max_length=255, blank=True, null=True),
|
||||
),
|
||||
]
|
||||
@@ -1,16 +0,0 @@
|
||||
from django.db import migrations
|
||||
|
||||
def fix_historical_records(apps, schema_editor):
|
||||
HistoricalPark = apps.get_model('parks', 'HistoricalPark')
|
||||
# Update any historical records that might have issues
|
||||
HistoricalPark.objects.filter(city__isnull=True).update(city=None)
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('parks', '0014_alter_location_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(fix_historical_records, migrations.RunPython.noop),
|
||||
]
|
||||
@@ -1,22 +0,0 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cities_light', '0011_alter_city_country_alter_city_region_and_more'),
|
||||
('parks', '0015_fix_historical_park_city_constraint'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='city',
|
||||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='cities_light.city'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='region',
|
||||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='cities_light.region'),
|
||||
),
|
||||
]
|
||||
@@ -1,22 +0,0 @@
|
||||
from django.db import migrations
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('parks', '0016_alter_historicalpark_city_nullable'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL(
|
||||
# Make the city column nullable
|
||||
sql='ALTER TABLE parks_historicalpark ALTER COLUMN city DROP NOT NULL;',
|
||||
# Reverse operation if needed
|
||||
reverse_sql='ALTER TABLE parks_historicalpark ALTER COLUMN city SET NOT NULL;'
|
||||
),
|
||||
migrations.RunSQL(
|
||||
# Make the city_id column nullable
|
||||
sql='ALTER TABLE parks_historicalpark ALTER COLUMN city_id DROP NOT NULL;',
|
||||
# Reverse operation if needed
|
||||
reverse_sql='ALTER TABLE parks_historicalpark ALTER COLUMN city_id SET NOT NULL;'
|
||||
),
|
||||
]
|
||||
@@ -1,48 +0,0 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cities_light', '0011_alter_city_country_alter_city_region_and_more'),
|
||||
('parks', '0017_fix_historicalpark_city_column'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='country',
|
||||
field=models.ForeignKey(
|
||||
blank=False,
|
||||
db_constraint=False,
|
||||
null=False,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name='+',
|
||||
to='cities_light.country'
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='region',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name='+',
|
||||
to='cities_light.region'
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalpark',
|
||||
name='city',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name='+',
|
||||
to='cities_light.city'
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -1,15 +0,0 @@
|
||||
from django.db import migrations
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('parks', '0018_fix_historicalpark_location_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL(
|
||||
# Make region_id nullable
|
||||
sql='ALTER TABLE parks_historicalpark ALTER COLUMN region_id DROP NOT NULL;',
|
||||
reverse_sql='ALTER TABLE parks_historicalpark ALTER COLUMN region_id SET NOT NULL;'
|
||||
),
|
||||
]
|
||||
@@ -1,16 +0,0 @@
|
||||
from django.db import migrations
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('parks', '0019_fix_historicalpark_region_constraint'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL(
|
||||
# Remove the redundant city text column
|
||||
sql='ALTER TABLE parks_historicalpark DROP COLUMN IF EXISTS city;',
|
||||
# Recreate the column if needed (reverse migration)
|
||||
reverse_sql='ALTER TABLE parks_historicalpark ADD COLUMN city character varying(255);'
|
||||
),
|
||||
]
|
||||
@@ -1,32 +0,0 @@
|
||||
# Generated by Django 5.1.2 on 2024-11-01 00:24
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("cities_light", "0011_alter_city_country_alter_city_region_and_more"),
|
||||
("parks", "0020_remove_historicalpark_city_text"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="historicalpark",
|
||||
name="country",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
to="cities_light.country",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="park",
|
||||
name="location",
|
||||
field=models.CharField(blank=True, max_length=255, null=True),
|
||||
),
|
||||
]
|
||||
Binary file not shown.
Reference in New Issue
Block a user