Hello;
I have a long running Django project; it started on version ~1.0. I have upgraded regularly and I am now on 1.10. I have been using migrations with Django since the became standard (1.8??) and generally been very happy with them. However today I am facing a problem with a migration which I have not been able to solve.
Initially I have a model Organisation:
class Organisation( Model ):
field1 = ... DB_COLUMN = "FIELD1")
field2 = ... DB_COLUMN = "FIELD2")
class Meta:
db_table = "ORGANISATIONS"
Observe that I have used the 'DB_COLUMN' and 'db_table' attributes to give non-standard names to columns and tables. The database was retrofitted to use Django, this is a relic from that conversion. Then today I added a small new 'model' for organisation type:
class OrganisationType( Modell );
id = ...
description = ...
Using makemigrations I first added a migration to create the OrganisationType model, and then subsequently I added empty/data migration to create one instance of the OrganisationType model. I then added a new ForeignKey on the Organisation model:
class Organisation( Model ):
....
org_type = ForeignKey( OrganisationType ,db_column = "ORGANISATION_TYPE")
Now when I try makemigrations it fails. The end of the traceback is:
django.db.utils.ProgrammingError: column ORGANISATIONS.ORGANISATION_TYPE does not exist
LINE 1: ...ES_UPDATED_BY", "ORGANISATIONS"."PRICES_UPDATED", "ORGANISAT...
So - it seems to be complaining that the 'ORGANISATION_TYPE' column is missing from the ORGANISATIONS table; now that makes sense - this was exactly the change I wanted a migration for! If I try other manage commands like `manage.py runserver` or `manage.py test` I get the same error.
Any hints?
Joakim