Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flyway Java migrations not working in command line tool

I just cannot get Java migrations get to be recognized and executed using the flyway command line tool.

What I did so far:

  1. Download and extract Flyway (commandline version)
  2. Configured flyway.properties in the conf directory, setting the following properties
    • flyway.driver, flyway.url, flyway.user, flyway.password
  3. Added oracle JDBC driver to the jars directory
  4. Executed flyway.cmd init => Worked. History table was created.
  5. Added an SQL File to the ./sql directory V1_1__Some_sql.sql
  6. Executed flyway.cmd migrate => worked. DB was changed

    FINE SO FAR. Works as expected. Now the problematic part:

  7. Created a Java class in my IDE.

    public class V1_2__Another_test implements JdbcMigration 
    {
    
       public void migrate(Connection connection) throws Exception 
       {
    
          PreparedStatement statement = connection.prepareStatement("INSERT INTO flyway_sample (name) VALUES ('My Name')");
    
          try {
             statement.execute();
          } finally {
             statement.close();
          }
       }
    }
    
  8. Compiled the class, put it into a jar with name V1_2__Another_test.jar

  9. Placed the jar in sql or jars and tried to run flyway.cmd migrate. => Flyway ignores it.
  10. Tried to put the .class file into jars or sql => Flyway also ignores it.
  11. I use Flyway 2.1.1.

What am I missing?

like image 651
magicroomy Avatar asked Dec 07 '25 09:12

magicroomy


1 Answers

What you did sounds fine. Make sure to add the package where your class resides to flyway.locations and you should be good to go.

like image 145
Axel Fontaine Avatar answered Dec 09 '25 21:12

Axel Fontaine