Flyway Locations Property Not Being Set

Viewed 934

Flyway does not seem to be able to resolve classpath, despite the migrations being in there. What am I doing wrong here?

➜  my-project git:(main) ✗ flyway migrate
Flyway Community Edition 7.0.4 by Redgate
ERROR: Unable to resolve location classpath:db/migration.
Database: jdbc:mysql://localhost:3306/adb (MySQL 8.0)
Successfully validated 0 migrations (execution time 00:00.051s)
WARNING: No migrations found. Are your locations set up correctly?
Current version of schema `adb`: << Empty Schema >>
Schema `adb` is up to date. No migration necessary.

flyway.conf

flyway.url=jdbc:mysql://localhost:3306/adb
flyway.user=root
flyway.password=my-secret-pw
flyway.locations=db/migration/

Tree

➜  my-project git:(main) ✗ tree .
.
├── README.md
├── db
│   └── migration
│       ├── V1.0__create_foo_table.sql
│       ├── V2.0__create_bar_table.sql
│       └── V3.0__alter_bar_table.sql
├── flyway.conf

I've also tried an absolute path with no luck

2 Answers

Figured it out - forgot the filesystem: prepend

flyway.locations=filesystem:db/migration/

I experienced another reason for migration scripts not being found with Flyway 7.8.2.

If the Flyway process does not have read access to the script, rather than printing an error, it simply ignores the files exist.

Found this while using the Flyway Docker image within AWS Codepipeline. The image runs the process as a user called 'flyway'. Codepipeline somehow strips the "excess" permissions from the files on upload. So needed to "chmod 0444" files before using Flyway.

Also recommend using the -X flyway option, to list what it is doing.

Related