diff --git a/forecastmanager/migrations/0013_alter_city_options_alter_forecast_unique_together_and_more.py b/forecastmanager/migrations/0013_alter_city_options_alter_forecast_unique_together_and_more.py index dff7d9e..d6bfef6 100644 --- a/forecastmanager/migrations/0013_alter_city_options_alter_forecast_unique_together_and_more.py +++ b/forecastmanager/migrations/0013_alter_city_options_alter_forecast_unique_together_and_more.py @@ -1,17 +1,25 @@ # Generated by Django 4.2.3 on 2024-03-05 12:41 -from django.db import migrations, models import django.db.models.deletion import modelcluster.fields +from django.db import migrations, models -class Migration(migrations.Migration): +def delete_existing_forecasts(apps, schema_editor): + model = apps.get_model('forecastmanager', 'forecast') + model.objects.all().delete() + +class Migration(migrations.Migration): dependencies = [ ('forecastmanager', '0012_alter_forecastperiod_forecast_effective_time'), ] operations = [ + migrations.RunPython( + delete_existing_forecasts, + migrations.RunPython.noop + ), migrations.AlterModelOptions( name='city', options={'ordering': ['name'], 'verbose_name': 'City', 'verbose_name_plural': 'Cities'}, @@ -28,7 +36,9 @@ class Migration(migrations.Migration): ('symbol', models.CharField(max_length=100, verbose_name='Weather Symbol')), ('label', models.CharField(max_length=100, unique=True, verbose_name='Label')), ('alias', models.CharField(blank=True, max_length=100, null=True, unique=True, verbose_name='Alias')), - ('parent', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='weather_conditions', to='forecastmanager.forecastsetting')), + ('parent', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, + related_name='weather_conditions', + to='forecastmanager.forecastsetting')), ], options={ 'ordering': ['sort_order'], @@ -40,9 +50,13 @@ class Migration(migrations.Migration): fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('sort_order', models.IntegerField(blank=True, editable=False, null=True)), - ('city', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='forecastmanager.city', verbose_name='City')), - ('condition', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='forecastmanager.weathercondition')), - ('parent', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='city_forecasts', to='forecastmanager.forecast')), + ('city', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='forecastmanager.city', + verbose_name='City')), + ('condition', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, + to='forecastmanager.weathercondition')), + ('parent', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, + related_name='city_forecasts', + to='forecastmanager.forecast')), ], options={ 'unique_together': {('parent', 'city')}, @@ -66,8 +80,11 @@ class Migration(migrations.Migration): ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('sort_order', models.IntegerField(blank=True, editable=False, null=True)), ('value', models.CharField(blank=True, max_length=255, null=True, verbose_name='Value')), - ('parameter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='data_values', to='forecastmanager.forecastdataparameters')), - ('parent', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='data_values', to='forecastmanager.cityforecast')), + ('parameter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='data_values', + to='forecastmanager.forecastdataparameters')), + ('parent', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, + related_name='data_values', + to='forecastmanager.cityforecast')), ], options={ 'unique_together': {('parent', 'parameter')}, diff --git a/setup.cfg b/setup.cfg index 6fa4d0f..40bfcf3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = forecastmanager -version = 0.4.0 +version = 0.4.1 description = Integration of Weather City Forecasts Manager in Wagtail Projects. long_description = file:README.md long_description_content_type = text/markdown