升级指南

数据库升级

位于 alembic_migrations/versions 中的迁移文件包含迁移 Mistral 数据库修订版本所需的更改。 迁移是通过执行详细说明升级数据库所需更改的脚本来完成的。 迁移脚本按顺序排列,以便可以按顺序运行多个脚本。 脚本由 Mistral 的迁移包装器执行,该包装器使用 Alembic 库来管理迁移。 Mistral 支持从 Kilo 或更高版本进行迁移。

您可以通过以下方式升级到最新的数据库版本:

$ mistral-db-manage --config-file /path/to/mistral.conf upgrade head

您可以将数据库填充为标准操作和工作流程

$ mistral-db-manage --config-file /path/to/mistral.conf populate

要检查当前的数据库版本

$ mistral-db-manage --config-file /path/to/mistral.conf current

要创建脚本以离线运行迁移

$ mistral-db-manage --config-file /path/to/mistral.conf upgrade head --sql

要运行特定迁移版本之间的离线迁移

$ mistral-db-manage --config-file /path/to/mistral.conf upgrade <start version>:<end version> --sql

增量升级数据库

$ mistral-db-manage --config-file /path/to/mistral.conf upgrade --delta <# of revs>

或者,将数据库升级到一个较新的修订版本

$ mistral-db-manage --config-file /path/to/mistral.conf upgrade +1

创建新的修订版本

$ mistral-db-manage --config-file /path/to/mistral.conf revision -m "description of revision" --autogenerate

创建一个空白文件

$ mistral-db-manage --config-file /path/to/mistral.conf revision -m "description of revision"

此命令不执行任何迁移,它仅设置修订版本。 修订版本可以是任何现有的修订版本。 请谨慎使用此命令。

$ mistral-db-manage --config-file /path/to/mistral.conf stamp <revision>

要验证时间线是否分支,您可以运行此命令

$ mistral-db-manage --config-file /path/to/mistral.conf branches

如果迁移路径有分支,您可以通过以下方式找到分支点:

$ mistral-db-manage --config-file /path/to/mistral.conf history