问题:
alembic.util.exc.CommandError: Can't locate revision identified by 'b44ffb6f5dc6'
部署Flask到Heroku后,如果后台数据库更改了表格、column等,本地用 Alembic很容易完成 db migration。
然后 git add/commit/push heroku后,数据库 migrate就会失败!
c:\git\tmp\tianya>heroku run bash
Running bash on tianya... up, run.2000 (Free)
~ $ python manage.py db upgrade
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
Traceback (most recent call last):
File "manage.py", line 110, in <module>
manager.run()
...
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/script/revision.py", line 359, in _revision_for_ident
resolved_id)
alembic.util.exc.CommandError: Can't locate revision identified by 'b44ffb6f5dc6'</span>
原因:
本地是用 sqlite,远程是用 Postgres,使用 Alembic db init / db migrate / db upgrade之后,会在数据库里创建新表格 alembic_version:
但本地和远程的 Alembic migrati