djangodjango-migrations

Django Programming error column does not exist even after running migrations


I run python manage.py makemigrations and I get: No changes detected Then, python manage.py migrate and I get: No migrations to apply.

Then, I try to push the changes to production: git push heroku master Everything up-to-date

Then, in production, I repeat the command: heroku run python manage.py migrate No migrations to apply.

Just in case, I run makemigrations in production:

heroku run python manage.py makemigrations
No changes detected

WHY then I get a

ProgrammingError at ....

column .... does not exist

"No changes detected" means the database is coherent with the code. How can I debug this?¡?


Solution

  • Django migrations are recorded in your database under the 'django_migrations' table. This is how Django knows which migrations have been applied and which still need to be applied.

    Have a look at django_migrations table in your DB. It may be that something went wrong when your migration was applied. So, delete the row in the table which has the migration file name that is related to that column that 'does not exist'. Then, try to re-run a migration.