How can I start the migration on Irok?

I am using FlywayDB for porting in a Maven Java project. I am currently working on making hosting possible on Heroku.

On my local machine, I am using the Maven Flyway plugin to run the migration:

$> mvn clean compile flyway:migrate

To do the same on herok, I would usually try:

$> heroku run mvn flyway:migrate

However, mvn is not available after the build phase, so this results in an error ( mvn: command not found

)

How can I migrate on route to Heroku?

+3


source to share


2 answers


I think it is best to create a small class in your application that uses the FlywayDB API. It might look like this:

class Migrator {
  public static void main(String[] args) throws Exception {
    ...
    Flyway flyway = new Flyway();
    flyway.setDataSource(url, user, password);
    flyway.migrate();
  }
}

      

Then create an entry Procfile

like this:



migrate: java -cp target/classes:target/dependency/* Migrator

      

Finally, run it if needed heroku run migrate

.

The reason Heroku doesn't include Maven in the slug (i.e. at runtime) is because the directory is .m2

not being saved. If Maven was enabled and then you ran the command mvn

, you had to download the internet first. The catalog is .m2

not saved because the stock is too large.

+3


source


According to Heroku documentation , using Maven plugin is not recommended for Flyway migration.

There are two alternatives in the documentation:



0


source







All Articles