Stack
PostgresQL 9.3 on Ubuntu 18.04
Django 3.0 with DRF
Problem
I am trying to build a model with the below desired models.py. But I used the pythonic way to name variables, but I now realize that PostgreSQL ignores the "_", thus "region" and "region_number" appear to be the same key.
region_number should be regionNumber
My question is how to I correct this?
What I have tried:
- Simply correcting the model element names and migrating - error is still there
- Migrating back to before I applied this migration
- Dropping the Index in SQL; returns "cannot drop index XXX_Index because constraint XXX_Index on table (my_table_name) requires it
CURRENT models.py
from django.db import models
class DataInput(models.Model):
name = models.CharField(max_length=45)
country = models.CharField(max_length=55)
region = models.CharField(max_length=55)
region_number = models.IntegerField()
Error python manage.py migrate
psycopg2.errors.UniqueViolation: could not create unique index "Region and Number"
DETAIL: Key (region, region_number)=(US EAST, 1) is duplicated.
DESIRED models.py
from django.db import models
class DataInput(models.Model):
name = models.CharField(max_length=45)
country = models.CharField(max_length=55)
region = models.CharField(max_length=55)
regionNumber = models.IntegerField()