I am using the flyway command line tool to handle my db migrations. So far, all migrations have been sql
Configuration file (only used options):
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
This works great.
But now I need to add one Java-based port. And I'm really puzzled. I can't find any examples. How to compile where to transfer java migrations.
I tried a simple migration class from official documentation:
package db.migration; import org.flywaydb.core.api.migration.jdbc.JdbcMigration; import java.sql.Connection; import java.sql.PreparedStatement; 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(); } } }
But what to do next? Tried compiling:
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
And then, putting this jar in different locations has no effect.
information about the flyway - I do not see migration.
So, how to create a simple Java based migration. I would rather not use Maven, or something like that. Just a simple jar (???) file that is matched using the flyway command-line tool.
Thanks.
source share