Skip to content

Commit

Permalink
Delete existing forecasts before running new breaking migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
erick-otenyo committed Mar 15, 2024
1 parent 9c2ba23 commit 64262fa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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'},
Expand All @@ -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'],
Expand All @@ -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')},
Expand All @@ -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')},
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 64262fa

Please sign in to comment.