Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flyway - Cannot find migrations location in

I can't seem to let flyway know where to look for my migrations. My file structure is the default generated from spring initializr. My migrations are in: ./demo/src/main/kotlin/db/migration My migrations are java based

My application.properties file looks like this:

spring.datasource.driverClassName=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.url=jdbc:postgresql://${JDBC_DATABASE_URL}/jpaTestDatabase
spring.datasource.username=${JDBC_DATABASE_USERNAME}
spring.datasource.password=${JDBC_DATABASE_PASSWORD}

spring.flyway.baseline-on-migrate=true
spring.flyway.locations=classpath:demo/src/main/kotlin/db/migration

spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=validate
spring.session.store-type=none

I tried several classpaths:

/demo/src/main/kotlin/db/migration
demo/src/main/kotlin/db/migration
/src/main/kotlin/db/migration
src/main/kotlin/db/migration

None of the above seem to work.

How can I let flyway know where the migrations are?

like image 968
PaulB Avatar asked Nov 06 '18 13:11

PaulB


Video Answer


2 Answers

I had a different problem, my migration file name was V1_Base_version.sql instead of V1__Base_version.sql. Flyway requires double underscore __ in name prefix.

like image 180
Oleksandr.Bezhan Avatar answered Sep 21 '22 15:09

Oleksandr.Bezhan


By default Flyway will look for migrations on the classpath under db/migration, which on a Maven project means src/main/resources/db/migration.

Ensure that you have directory like this.

Refer flyway-db-migration-folder

like image 29
Alien Avatar answered Sep 22 '22 15:09

Alien