#Django makemigrations is giving an error...

2 messages · Page 1 of 1 (latest)

upbeat tide
#

This is a very bizarre issue....

I am trying to add new fields to a model:

  • It doesn't matter what name I give to this field in this particular app but I get an error as follows: django.db.utils.ProgrammingError: column events_eventsetting.electronic_signature_disclosure_and_consent does not exist (insert ANY name you want)
  • I have checked all migration files repeatedly for the existence of this field name...nada.
  • I have checked the DB table through PGAdmin...nada
  • I have checked for all references to this field in all files in the project through the IDE...nada.

Here's an example of the code I'm adding:


YES_NO_CHOICES = [
    ('No', 'No'),
    ('Yes', 'Yes'),
]
# SNIP
class EventSetting(models.Model):
    liability_active = models.CharField(
        max_length=5,
        choices=YES_NO_CHOICES,
        default='No',
    )
# SNIP

I have added fields to this model before...a number of times. All migration files are accounted for. All file numbers are sequential. The IDE shows them all as uploaded to the repo.

This is an odd one. I am using this particular table as a global settings table so there is only one row in the table. I have checked, through the IDE, for references to this table (EventSettings) and utilize constants.

Thoughts?

upbeat tide
#

I'm going to ditch this table and rebuild a GlobalSettings table. Thankfully, whatever this is can be bypassed for this project. And whatever it is is a bug with Django.

The downside is I don't know what cause is or how to replicate...so it's challenging to submit as a bug. However, I've bumped into reports of this as an issue. Previously, I commented out all references to this table in all over files and that worked. But it's gotten to the point where that doesn't resolve the issue anymore. sigh

My sense is that makemigrations is validating existence of any tables being migrated and checking something behind the scenes. However, there's something in that validation that is tripping up if there's reference to a table that it sees a problem with.

It doesn't matter how you slice it...an error message telling you a field you are trying to add in makemigrations does not exist does not make sense.