flyway7.1.1适配人大金仓postgres版本

2023-10-16 20:00:01 浏览数 (1)

1、进入flyway github仓库下载flyway7.1.1版本源码,搜索7.1.1,下载地址为:https://github.com/flyway/flyway/releases

2、解压源码, 新建目录kingbase,将postgres目录文件拷贝进kingbase,修改下文件名:

3、修改KingbaseDatabaseType文件,源码如下:

代码语言:javascript复制
public class KingbaseDatabaseType extends DatabaseType {
    @Override
    public String getName() {
        return "Kingbase8";
    }

    @Override
    public int getNullType() {
        return Types.NULL;
    }

    @Override
    public boolean handlesJDBCUrl(String url) {
        if (url.startsWith("jdbc-secretsmanager:postgresql:")) {




            throw new org.flywaydb.core.internal.license.FlywayTeamsUpgradeRequiredException("jdbc-secretsmanager");

        }

        return url.startsWith("jdbc:kingbase8:");
    }

    @Override
    public String getDriverClass(String url, ClassLoader classLoader) {
        return "com.kingbase8.Driver";
    }

    @Override
    public boolean handlesDatabaseProductNameAndVersion(String databaseProductName, String databaseProductVersion, Connection connection) {
        return databaseProductName.startsWith("KingbaseES");
    }

    @Override
    public Database createDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor) {
        return new KingbaseDatabase(configuration, jdbcConnectionFactory, statementInterceptor);
    }

    @Override
    public Parser createParser(Configuration configuration, ResourceProvider resourceProvider, ParsingContext parsingContext) {
        return new KingbaseParser(configuration, parsingContext);
    }

    @Override
    public void setDefaultConnectionProps(String url, Properties props, ClassLoader classLoader) {
        props.put("applicationName", APPLICATION_NAME);
    }

    @Override
    public boolean detectUserRequiredByUrl(String url) {
        return !url.contains("user=");
    }

    @Override
    public boolean detectPasswordRequiredByUrl(String url) {
        // Postgres supports password in URL
        return !url.contains("password=");
    }

4、修改DatabaseTypeRegister文件,在registerDatabaseTypes增加kingbase类型

代码语言:javascript复制
registeredDatabaseTypes.add(new KingbaseDatabaseType());

5、修改下flyway-parent版本为7.1.1.1,flyway-core parent版本修改为7.1.1.1

6、执行mvn install -Dmaven.test.skip=true 打包即可

0 人点赞