Want to deploy your JVM, Node.js and Go apps effortlessly to AWS? Try our service Boxfuse

Maven Plugin

Supported Maven Versions

  • Maven 2.2.1
  • Maven 3.x

Installation

<plugin>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-maven-plugin</artifactId>
    <version>4.2.0</version>
    <configuration>
        ....
    </configuration>
</plugin>

Goals

Name Description
migrate Migrates the database
clean Drops all objects in the configured schemas
info Prints the details and status information about all the migrations
validate Validates the applied migrations against the ones available on the classpath
baseline Baselines an existing database, excluding all migrations up to and including baselineVersion
repair Repairs the metadata table

Configuration

The Flyway Maven plugin can be configured in the following ways:

Directly in the configuration of the plugin

<plugin>
    ...
    <configuration>
        <user>myUser</user>
        <password>mySecretPwd</password>
        <schemas>
            <schema>schema1</schema>
            <schema>schema2</schema>
            <schema>schema3</schema>
        </schemas>
        <placeholders>
            <keyABC>valueXYZ</keyABC>
            <otherplaceholder>value123</otherplaceholder>
        </placeholders>
    </configuration>
</plugin>
Limitation: Due to a long standing Maven bug it is not possible to configure empty values this way. You must use one of the other configurations ways instead.

Through Maven properties

<project>
    ...
    <properties>
        <!-- Properties are prefixed with flyway. -->
        <flyway.user>myUser</flyway.user>
        <flyway.password>mySecretPwd</flyway.password>

        <!-- List are defined as comma-separated values -->
        <flyway.schemas>schema1,schema2,schema3</flyway.schemas>

        <!-- Individual placeholders are prefixed by flyway.placeholders. -->
        <flyway.placeholders.keyABC>valueXYZ</flyway.placeholders.keyABC>
        <flyway.placeholders.otherplaceholder>value123</flyway.placeholders.otherplaceholder>
    </properties>
    ...
</project>

Through an external config file

> mvn -Dflyway.configFile=myConfig.properties

Default is flyway.properties in the same directory as the POM.
Encoding is specified by flyway.encoding (Default: UTF-8)

flyway.user=myUser
flyway.password=mySecretPwd
flyway.schemas=schema1,schema2,schema3
flyway.placeholders.keyABC=valueXYZ
flyway.placeholders.otherplaceholder=value123

Through System properties

> mvn -Dflyway.user=myUser -Dflyway.schemas=schema1,schema2 -Dflyway.placeholders.keyABC=valueXYZ

Overriding order

System properties override External config file overrides Maven properties override Plugin configuration

Authentication

Besides configuring credentials through one of the 3 ways described above, it is also possible to externalize them in the Maven settings.xml file:

<settings>
    <servers>
        <server>
            <!-- By default Flyway will look for the server with the id 'flyway-db' -->
            <!-- This can be customized by configuring the 'serverId' property -->
            <id>flyway-db</id>
            <username>myUser</username>
            <password>mySecretPwd</password>
        </server>
    </servers>
</settings>

Maven: migrate