sedavidw sedavidw - 3 months ago 56
Python Question

Django 1.7 Migrations hanging

I have a django migration I am trying to apply. It gets made fine (it's small, it's only adding a

to two different Models. However when I run the actual migrate it hangs (no failure, no success, just sits).

Through googling I've found that other open connections can mess with it so I restarted the DB. However this DB is connect to continuously running jobs and new queries do sneak in right away. However they are small, and last time I tried restarting I THINK I was able to execute my migrate before anything else. Still nothing.

Are there any other known issues that cause something like this?


At least in PostgreSQL you cannot modify tables (even if it's just adding new columns) while there are active transactions. The easiest workaround for this is usually to:

  • run the migration script (which will hang)
  • restart your webserver/wsgi container

When restarting your webserver all open transactions will be aborted (assuming you don't have background processes which also have transactions open), so as soon as no transactions are blocking your table, the migration will finish.