From 8020fa955e6739d982c0b45af6d338653bea7bd6 Mon Sep 17 00:00:00 2001 From: "app@gmba.django-hosting.ch" Date: Tue, 30 Nov 2021 09:13:55 +0100 Subject: [PATCH] Remove foreign key dependency range <-> rangeonlineinfo --- .../0048_alter_rangeonlineinfo_range_name.py | 19 +++++++++++++++++++ .../0049_alter_rangeonlineinfo_range_name.py | 18 ++++++++++++++++++ ...050_alter_mountainrange_range_name_map.py} | 9 ++------- app/models.py | 4 +++- 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 app/migrations/0048_alter_rangeonlineinfo_range_name.py create mode 100644 app/migrations/0049_alter_rangeonlineinfo_range_name.py rename app/migrations/{0048_auto_20211129_0412.py => 0050_alter_mountainrange_range_name_map.py} (54%) diff --git a/app/migrations/0048_alter_rangeonlineinfo_range_name.py b/app/migrations/0048_alter_rangeonlineinfo_range_name.py new file mode 100644 index 0000000..ece33da --- /dev/null +++ b/app/migrations/0048_alter_rangeonlineinfo_range_name.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.5 on 2021-11-30 08:08 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0047_alter_mountainrange_area'), + ] + + operations = [ + migrations.AlterField( + model_name='rangeonlineinfo', + name='range_name', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='app.mountainrange', to_field='range_name_map'), + ), + ] diff --git a/app/migrations/0049_alter_rangeonlineinfo_range_name.py b/app/migrations/0049_alter_rangeonlineinfo_range_name.py new file mode 100644 index 0000000..ebdc393 --- /dev/null +++ b/app/migrations/0049_alter_rangeonlineinfo_range_name.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.5 on 2021-11-30 08:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0048_alter_rangeonlineinfo_range_name'), + ] + + operations = [ + migrations.AlterField( + model_name='rangeonlineinfo', + name='range_name', + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/app/migrations/0048_auto_20211129_0412.py b/app/migrations/0050_alter_mountainrange_range_name_map.py similarity index 54% rename from app/migrations/0048_auto_20211129_0412.py rename to app/migrations/0050_alter_mountainrange_range_name_map.py index 3af8484..ac79a3d 100644 --- a/app/migrations/0048_auto_20211129_0412.py +++ b/app/migrations/0050_alter_mountainrange_range_name_map.py @@ -1,4 +1,4 @@ -# Generated by Django 3.2.5 on 2021-11-29 04:12 +# Generated by Django 3.2.5 on 2021-11-30 08:09 from django.db import migrations, models @@ -6,7 +6,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('app', '0047_alter_mountainrange_area'), + ('app', '0049_alter_rangeonlineinfo_range_name'), ] operations = [ @@ -15,9 +15,4 @@ class Migration(migrations.Migration): name='range_name_map', field=models.CharField(blank=True, max_length=128, null=True), ), - migrations.AlterField( - model_name='rangeonlineinfo', - name='range_name', - field=models.TextField(blank=True, null=True), - ), ] diff --git a/app/models.py b/app/models.py index 85fb6a9..816ba00 100644 --- a/app/models.py +++ b/app/models.py @@ -89,6 +89,7 @@ class MountainRange(models.Model): countries = models.TextField(blank=True, null=True) range_name_map = models.CharField(blank=True, null=True, max_length=128) + #range_name_map = models.CharField(blank=True, null=True, unique=True, max_length=128) range_name = models.CharField(blank=True, null=True, max_length=128) range_name_ascii = models.CharField(blank=True, null=True, max_length=128) range_name_language = models.ForeignKey(Language, models.DO_NOTHING, blank=True, null=True, to_field='id') @@ -428,7 +429,8 @@ class RangeOnlineInfo(models.Model): id = models.AutoField(primary_key=True) # This is supposed to be linked to MountainRange via range_name_map, but the range_name_map # is not itself unique. Are we missing something? TODO: Investigate - # range_name = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True, to_field='range_name_map') + #range_name = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True, to_field='range_name_map') + #range_name = models.ForeignKey(MountainRange, blank=True, null=True, to_field='range_name_map', on_delete=models.CASCADE) range_name = models.TextField(blank=True, null=True) info_source = models.TextField(blank=True, null=True) url = models.TextField(blank=True, null=True)