【问题标题】:Is there an way with flask-migrate/alembic to list migrations that have been applied to a DB?flask-migrate/alembic 有没有办法列出已应用于数据库的迁移?
【发布时间】:2019-06-12 22:47:52
【问题描述】:

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

我正在寻找相当于 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

【问题讨论】:

    标签: python flask sqlalchemy alembic flask-migrate


    【解决方案1】:

    您可以通过运行flask db history 列出所有步骤并标记当前版本。

    • 添加-i / --indicate-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.
    

    【讨论】:

      猜你喜欢
      • 2015-12-24
      • 2021-11-08
      • 2016-05-21
      • 1970-01-01
      • 2013-07-31
      • 2014-02-24
      • 1970-01-01
      • 2013-07-04
      • 2018-10-24
      相关资源
      最近更新 更多