mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-21 13:31:09 -05:00
fixed the damn discord button
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# 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
|
||||
),
|
||||
),
|
||||
]
|
||||
23
parks/migrations/0005_update_country_field_length.py
Normal file
23
parks/migrations/0005_update_country_field_length.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# 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),
|
||||
),
|
||||
]
|
||||
125
parks/migrations/0006_update_location_fields_to_cities_light.py
Normal file
125
parks/migrations/0006_update_location_fields_to_cities_light.py
Normal file
@@ -0,0 +1,125 @@
|
||||
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'),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user