Debug flask-migrate

Viewed 315

Upon editing my models, I wanted to use flask db migrate to update my database. However flask db migrate doesn't seem to detect my models anymore?

Currently I get the following output:

INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

And that's it.

I have searched for problems other users had, but it did not lead to a solution for me. Basically I was following the Flask Mega-Tutorial, so my code looks very similar (with the blueprints).

What I am asking for is a set of commands/things I could do, to determine what the actual issue is. How can I determine that my modules are found? That the database is found? That it looks at the changes?


Currently I have checked:

  • importing the models
  • having a database present
  • remove whole 'migration' folder, flask db init and then try to migrate again
2 Answers

I had the same problem now for a while and started debugging alembic. Apparently when it tried to run my env.py file it failed somewhere there with a 'CommandError: Target database is not up to date.'

Sadly I couldn't pinpoint the exact source of the error 'cause at this point I deleted the whole local repository, dropped the DB and fetched the code again from our GitLab. Also my colleauges had no such error so it must have been some local problem with my db.

Make sure your model has been imported by your app. In most cases, your views.py file should contain your models.

Related