【发布时间】:2019-09-16 04:17:26
【问题描述】:
我想知道 flyway 是否有某种预定义的占位符,我们可以在 SQL 迁移脚本中使用?
我要做的是在切换回数据库之前在 master 数据库中执行一些命令,然后再运行迁移。
我的脚本应该是这样的:
USE master
-- Create things, make a small dynamic SQL string and run it in the context of my DB
${myMigrationDB}..sp_executesql @myDynamicSQL;
USE ${myMigrationDB}
-- Execute something else in the context of the db defined in flyway.url that will use what has been created previously
我知道我可以创建自己的占位符来保存数据库名称,但在我看来,我会重复一些已经可用的东西,因为它在我的 flyway.url 的配置文件中
我也知道我可以在单独的迁移中运行第二部分,但我仍然需要使用 ${myMigrationDB}..sp_executesql @myDynamicSQL; 运行该动态 SQL
【问题讨论】:
标签: sql-server database-migration flyway