根据老外的方法解决了,自己翻译了一下https://blog.fossasia.org/tag/event/
报错如下
alembic.util.exc.CommandError: Multiple head revisions are present for given argument ‘head’; please specify a specific target revision, ‘<branchname>@head’ to narrow to a specific head, or ‘heads’ for all heads
是因为有两个开发人员在同时提交migrations时没有合并各自的head为一个统一的head
首先获取这两个head的id
$ python manage.py db heads
e38935822969 (head)
f55fde3d62b1 (head)
然后合并它们
$ python manage.py db merge e38935822969 f55fde3d62b1
Generating /vagrant/migrations/versions/ecb671d1eb4b_.py … done
更新到数据库
$ python manage.py db upgrade
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running upgrade 00ea66754d06 -> d84f976530e1, empty message
INFO [alembic.runtime.migration] Running upgrade d84f976530e1 -> 1b3e4f5f56bd, empty message
INFO [alembic.runtime.migration] Running upgrade 1b3e4f5f56bd -> e38935822969, empty message
INFO [alembic.runtime.migration] Running upgrade e38935822969, f55fde3d62b1 -> ecb671d1eb4b, empty message
然后migrate和upgrade
$ python manage.py db migrate
NFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.ddl.postgresql] Detected sequence named ‘role_id_seq’ as owned by integer column ‘role(id)’, assuming SERIAL and omitting
INFO [alembic.ddl.postgresql] Detected sequence named ‘microlocation_id_seq’ as owned by integer column ‘microlocation(id)’, assuming SERIAL and omitting….
$ python manage.py db upgrade
.....