flask-migrate/alembic 有没有办法列出已应用于数据库的迁移?

Is there an way with flask-migrate/alembic to list migrations that have been applied to a DB?

我想列出所有迁移和数据库状态(是否已应用迁移)。

我正在寻找 rails rake db:migrate:status.

的等价物

来自 rake db:migrate:status 的示例输出:

database: dev

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20180108162849  Add user table
   up     20180110135954  Add article table
  down    20180130152036  Add index to user

您可以列出所有步骤,并标记当前修订,运行 flask db history

  • 添加-i/--indicate-current开关来标记数据库的'current'状态
  • 使用 -v / --verbose 添加迁移脚本的完整路径和脚本头等信息。
$ flask db history --help
Usage: flask db history [OPTIONS]

  List changeset scripts in chronological order.

Options:
  -d, --directory TEXT    migration script directory (default is "migrations")
  -r, --rev-range TEXT    Specify a revision range; format is [start]:[end]
  -v, --verbose           Use more verbose output
  -i, --indicate-current  Indicate current version (Alembic 0.9.9 or greater
                          is required)
  --help                  Show this message and exit.