如何忽略Flyway的占位符表达式?

use*_*319 7 java mysql flyway

我正在使用flyway版本2.3,我有一个sql补丁,它将varchar插入到一个表中,该表具有Flyway视为占位符的字符序列.我想飞越忽略占位符并按原样运行脚本.

脚本文件是

insert into test_data (value) values ("${Email}");

Java代码是

package foobar;

import com.googlecode.flyway.core.Flyway;

public class App 
{
    public static void main( String[] args )
    {
        // Create the Flyway instance
        Flyway flyway = new Flyway();

        // Point it to the database
        flyway.setDataSource("jdbc:mysql://localhost:3306/flywaytest", "alpha", "beta");

        // Start the migration
        flyway.migrate();
    }
}
Run Code Online (Sandbox Code Playgroud)

小智 8

这可以通过在表达式中拆分$和{来完成:

insert into test_data (value) values ('$' || '{Email}')
Run Code Online (Sandbox Code Playgroud)


Axe*_*ine 6

您可以将占位符后缀或前缀的值更改为其他值,您应该没问题.