alembic post 迁移命令
alembic post migration commands
由于我们数据库中的一些问题,我们需要重新分配 table 所有者 post 创建。目前我们利用 Alembic - 有没有人有一种简单的方法来创建某种 post 挂钩,在迁移后运行某些 SQL 命令?
听起来您的要求可以通过编辑 alembic 的 env.py 文件来解决。来自 the docs(强调我的):
env.py - The env.py script is part of the generated environment so that the way
migrations run is entirely customizable. The exact specifics of how to
connect are here, as well as the specifics of how the migration
environment are invoked. The script can be modified so that multiple
engines can be operated upon, custom arguments can be passed into the
migration environment, application-specific libraries and models can
be loaded in and made available.
我打赌您可以通过在 run_migrations_online()
中添加一个调用来获得您想要的行为。
(假设您希望在每次迁移后 运行 post_hook。如果它是特定于迁移的,您可以在生成的迁移文件中更新 upgrade()
函数)
由于我们数据库中的一些问题,我们需要重新分配 table 所有者 post 创建。目前我们利用 Alembic - 有没有人有一种简单的方法来创建某种 post 挂钩,在迁移后运行某些 SQL 命令?
听起来您的要求可以通过编辑 alembic 的 env.py 文件来解决。来自 the docs(强调我的):
env.py - The env.py script is part of the generated environment so that the way migrations run is entirely customizable. The exact specifics of how to connect are here, as well as the specifics of how the migration environment are invoked. The script can be modified so that multiple engines can be operated upon, custom arguments can be passed into the migration environment, application-specific libraries and models can be loaded in and made available.
我打赌您可以通过在 run_migrations_online()
中添加一个调用来获得您想要的行为。
(假设您希望在每次迁移后 运行 post_hook。如果它是特定于迁移的,您可以在生成的迁移文件中更新 upgrade()
函数)