如何删除类似的 alembic 版本?

How do I delete a similar alembic version?

当我尝试做

alembic upgrade head

我收到这个错误:

ERROR [alembic.util.messaging] Online migration expected to match one row when updating '3aae6532b560' to 'a1d8dae7cc' in 'alembic_version'; 2 found
FAILED: Online migration expected to match one row when updating '3aae6532b560'
to 'a1d8dae7cc' in 'alembic_version'; 2 found

alembic current

给出两个相似版本的 alembic,如:

3aae6532b560
3aae6532b560

如何删除一个相似版本的 alembic,即复制的版本?

alembic 历史没有显示任何混乱的输出。

谢谢!

Alembic 版本存储在您的数据库中 alembic_version table。我看到您在 table.

中有两个相同的行

你可以这样做:

DELETE FROM alembic_version WHERE version_num='3aae6532b560';
INSERT INTO alembic_version VALUES ('3aae6532b560');

上述查询可以通过限制删除行的数量在一个查询中完成,但不同数据库引擎之间的 DELETE 查询限制是不同的。