Olivier Grégoire
Olivier Grégoire

Reputation: 35437

Change flyway-maven-plugin's default scripts directory

How can I change the following flyway-maven-plugin configuration so that I can drop my scripts in src/main/database instead of src/main/resources/db/migration?

The migrate mojo source code seems to indicate that the default value is db/migration, but what about the src/main/resources/?

            <plugin>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <url>jdbc:h2:file:target/tmp</url>
                    <user>sa</user>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.h2database</groupId>
                        <artifactId>h2</artifactId>
                        <version>1.4.190</version>
                    </dependency>
                </dependencies>
            </plugin>

Upvotes: 2

Views: 2774

Answers (1)

Axel Fontaine
Axel Fontaine

Reputation: 35169

Set the locations property to the directory you want. Prefix with filesystem: if it lives on the filesystem instead of the classpath: http://flywaydb.org/documentation/maven/migrate.html

For your use case, use the following:

            <plugin>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <url>jdbc:h2:file:target/tmp</url>
                    <user>sa</user>
                    <locations>
                        <location>filesystem:src/main/database</location>
                    </locations>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.h2database</groupId>
                        <artifactId>h2</artifactId>
                        <version>1.4.190</version>
                    </dependency>
                </dependencies>
            </plugin>

Upvotes: 11

Related Questions