Reputation: 361
I see from some older questions and responses that Flyway was not very good at dealing with paths other than its default (the sql folder in the Flyway home folder), but that was back at V2 and it's now version 3. I'm finding this still does't work with the following setup;
in the conf folder is flyway.properties file with the following configuration;
flyway.user=flyway1
flyway.schemas=flyway1
flyway.url=jdbc:mysql://localhost
flyway.driver=com.mysql.jdbc.Driver
flyway.password=flyway1
flyway.baseDir=/home/vagrant/flyway-testing/sql
I have a single migration file in the sql folder with a single piece of DDL in it:
CREATE TABLE table1 (
column1 VARCHAR(10),
column2 DATE)
I'm running this command;
flyway -X -configFile=${HOME}/flyway-testing/conf/flyway.properties validate
with this result:
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/hsqldb-2.3.2.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/jtds-1.3.1.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/jna-3.3.0-platform.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/h2-1.3.170.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/postgresql-9.3-1102-jdbc4.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/derby-10.11.1.1.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/mariadb-java-client-1.1.7.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/jna-3.3.0.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/sqlite-jdbc-3.7.15-M1.jar
Database: jdbc:mysql://localhost:3306/ (MySQL 5.5)
DEBUG: DDL Transactions Supported: false
DEBUG: Schema: flyway1
DEBUG: Scanning for filesystem resources at '/home/vagrant/bin/flyway-3.1/sql' (Prefix: '', Suffix: '.sql')
DEBUG: Scanning for resources in path: /home/vagrant/bin/flyway-3.1/sql (/home/vagrant/bin/flyway-3.1/sql)
DEBUG: Filtering out resource: /home/vagrant/bin/flyway-3.1/sql/put-your-sql-migrations-here.txt (filename: put-your-sql-migrations-here.txt)
DEBUG: Spring Jdbc available: false
DEBUG: Validating migrations ...
DEBUG: Scanning for filesystem resources at '/home/vagrant/bin/flyway-3.1/sql' (Prefix: 'V', Suffix: '.sql')
DEBUG: Scanning for resources in path: /home/vagrant/bin/flyway-3.1/sql (/home/vagrant/bin/flyway-3.1/sql)
DEBUG: Filtering out resource: /home/vagrant/bin/flyway-3.1/sql/put-your-sql-migrations-here.txt (filename: put-your-sql-migrations-here.txt)
Validated 0 migrations (execution time 00:00.007s)
This shows that despite the flyway.baseDir property set to the root of my dummy project the app is using the root of the binary installation as the place to search for migrations. I may be expecting the wrong thing from he setting, but I cannot find a definitive list of the available properties for the command line anywhere. I am loosely following this blog! but it is quite old and the suggested configuration there is close to what I have I think (I'm trying to keep this testing as minimal as possible so excluded some things that I think I need default values for).
Can anyone explain how to correctly configure Flyway to use configuration and migrations, etc. (anything that is not provided by the application itself) from folders that are not embedded in the application folder hierarchy?
Upvotes: 1
Views: 5214
Reputation: 35169
Use the correct property and things should work.
Replace flyway.baseDir=/home/vagrant/flyway-testing/sql
with flyway.locations=filesystem:/home/vagrant/flyway-testing/sql
More info: http://flywaydb.org/documentation/commandline/migrate.html#locations
Upvotes: 5