我正在使用flyway命令行工具来处理我的数据库迁移.直到现在所有迁移都是sql
配置文件(仅使用选项):
flyway.url=jdbc:postgresql://db.host
flyway.user=user
flyway.password=password
flyway.table=flyway_migrations
flyway.locations=filesystem:/home/........./sql/migrations
flyway.sqlMigrationPrefix=update
flyway.validateOnMigrate=false
flyway.outOfOrder=true
Run Code Online (Sandbox Code Playgroud)
这非常有效.
但是现在我需要添加一个基于java的迁移.而我真的很困惑,我找不到任何如何todo的例子.如何编译,在哪里放置java迁移.
我从官方文档中尝试过简单的迁移类:
package db.migration;
import org.flywaydb.core.api.migration.jdbc.JdbcMigration;
import java.sql.Connection;
import java.sql.PreparedStatement;
/**
* Example of a Java-based migration.
*/
public class V50_121_1__update_notes implements JdbcMigration {
public void migrate(Connection connection) throws Exception {
PreparedStatement statement =
connection.prepareStatement("INSERT INTO test_user (name) VALUES ('Obelix')");
try {
statement.execute();
} finally {
statement.close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
但接下来该怎么办?尝试编译:
javac -cp "./flyway-core-3.2.1.jar" V50_121_1__update_notes.java
jar cf V50_121_1__update_dataNode_notes.jar V50_121_1__update_dataNode_notes.class
Run Code Online (Sandbox Code Playgroud)
然后把那个罐子放到不同的位置,没有任何效果.
飞路信息 - 看不到迁移.
那么如何构建最简单的基于java的迁移.我宁愿不使用Maven或类似的东西.简单的jar文件(???)由flyway命令行工具获取.
谢谢.