diff --git a/hub/migrations/0055_change_gss_uniqueness.py b/hub/migrations/0055_change_gss_uniqueness.py new file mode 100644 index 000000000..a15c3c71e --- /dev/null +++ b/hub/migrations/0055_change_gss_uniqueness.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.5 on 2023-11-07 15:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("hub", "0054_fill_datatype_area_type"), + ] + + operations = [ + migrations.AlterField( + model_name="area", + name="gss", + field=models.CharField(max_length=30), + ), + migrations.AlterUniqueTogether( + name="area", + unique_together={("gss", "area_type")}, + ), + ] diff --git a/hub/models.py b/hub/models.py index 8b89df025..97daff829 100644 --- a/hub/models.py +++ b/hub/models.py @@ -497,7 +497,7 @@ class Meta: class Area(models.Model): mapit_id = models.CharField(max_length=30) - gss = models.CharField(unique=True, max_length=30) + gss = models.CharField(max_length=30) name = models.CharField(max_length=200) area_type = models.ForeignKey(AreaType, on_delete=models.CASCADE) geometry = models.TextField(blank=True, null=True) @@ -541,6 +541,9 @@ def get_by_name(cls, name, area_type="WMC"): return area + class Meta: + unique_together = ["gss", "area_type"] + class AreaData(CommonData): area = models.ForeignKey(Area, on_delete=models.CASCADE)