占位符如何在Flyway中工作? [英] How do placeholders work in Flyway?
问题描述
我正在评估在我的项目中使用的Flyway.我们当前的SQL脚本包含URL之类的占位符,这些URL会根据环境(dev,qa,prod)而具有不同的域名.
I'm evaluating Flyway for use in my project. Our current SQL scripts contain placeholders for things like URLs which will have a different domain names depending on the environment (dev, qa, prod).
具体来说,我们可能会有类似INSERT的语句
Specifically, we might have INSERT statements like
INSERT INTO FEED VALUES ('app.${env.token}.company.org/feed1', 'My Feed');
$ {env.token}需要替换为'dev','qa'或'prod'.
${env.token} needs to be replaced with 'dev', 'qa', or 'prod'.
我们有大约50种不同的属性,可能需要在SQL脚本中进行替换.这些属性全部驻留在一个或两个属性文件中.
We have about 50 different properties that could potentially need replacement in SQL scripts. The properties all reside in one or two properties files.
是否可以运行Flyway Ant迁移任务,以便从属性文件中提取替换令牌和值?
推荐答案
当前提供占位符作为属性时,属性名称应以 flyway.placeholders为前缀.
Currently when supplying placeholders as properties, the property name should be prefixed with flyway.placeholders.
例如,可以直接将 $ {env.token} 占位符指定为此Ant属性: flyway.placeholders.env.token
For example the ${env.token} placeholder can be specified directly as this Ant property: flyway.placeholders.env.token
当前不支持在不使用属性名称前缀的情况下直接传递属性文件.随时在 问题跟踪器 中提出问题. :-)
There is currently no support for passing a property file directly, without using prefixes for the property names. Feel free to raise an issue in the Issue Tracker. :-)
这篇关于占位符如何在Flyway中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!