javaflyway

Flyway set location In java


I'm just using the latest version, and reading the documentation I cannot find a way programmatically to specify a flyway where are my migration v*_description.sql files that I have in the file-system. I cannot use location since I would like to use the Java API to do It.

There's an DSL to do that in your API or command-line is the only way?.

Regards


Solution

  • You can set the locations of your db migration files in Maven, Gradle or Java API.

    Maven:

    <flyway.locations>filesystem:src/main/resources/db/migration</flyway.locations>
    

    Gradle:

    locations = ['classpath:db/migration']
    

    Java:

    Flyway flyway = new Flyway();
    flyway.setDataSource(databaseUrl + databaseSchema, databaseUser, databasePassword);
    flyway.setLocations("DB_MIGRATION_LOCATIONS");
    flyway.migrate();