Maven Goal

Maven Plugin

The Flyway Maven plugin supports Maven 3.x running on Java 17.


Flyway Community Edition

This includes Teams & Enterprise features subject to license.

See Upgrading to Teams or Enterprise to find out about the edition contents


By downloading Flyway Community Maven Plugin you confirm that you have read and agree to the terms of the Redgate EULA.

Please note, the groupId changed at Flyway V10.0.0 from org.flywaydb.enterprise to com.redgate.flyway.

For older versions see Accessing Older Versions of Flyway Engine

Open Source Edition




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
undo Flyway Teams Undoes the most recently applied versioned migration
baseline Baselines an existing database, excluding all migrations up to and including baselineVersion
repair Repairs the schema history table


The Flyway Maven plugin can be configured in a wide variety of following ways, which can all be combined at will.

Configuration section of the plugin

The easiest way is to simply use the plugin's configuration section in your pom.xml:

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.

Maven properties

To make it easy to work with Maven profiles and to logically group configuration, the Flyway Maven plugin also supports Maven properties:

        <!-- Properties are prefixed with flyway. -->

        <!-- List are defined as comma-separated values -->

        <!-- Individual placeholders are prefixed by flyway.placeholders. -->


For storing the database user and password, Maven settings.xml files can also be used:

            <!-- By default Flyway will look for the server with the id 'flyway-db' -->
            <!-- This can be customized by configuring the 'serverId' property -->

Both regular and encrypted settings files are supported.

Environment Variables

To make it easy to work with cloud and containerized environments, Flyway also supports configuration via environment variables. Check out the Flyway environment variable reference for details.

System properties

Configuration can also be supplied directly via the command-line using JVM system properties:

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

Config files

Config files are supported by the Flyway Maven plugin. If you are not familiar with them, check out the Flyway config file structure and settings reference first.

Flyway will search for and automatically load the <user-home>/flyway.conf config file if present.

It is also possible to point Flyway at one or more additional config files. This is achieved by supplying the System property flyway.configFiles as follows:

> mvn -Dflyway.configFiles=path/to/myAlternativeConfig.conf flyway:migrate

To pass in multiple files, separate their names with commas:

> mvn -Dflyway.configFiles=path/to/myAlternativeConfig.conf,other.conf flyway:migrate

Relative paths are relative to the directory containing your pom.xml file.

Alternatively you can also use the FLYWAY_CONFIG_FILES environment variable for this. When set it will take preference over the command-line parameter.

> export FLYWAY_CONFIG_FILES=path/to/myAlternativeConfig.conf,other.conf

By default Flyway loads configuration files using UTF-8. To use an alternative encoding, pass the system property flyway.configFileEncoding as follows:

> mvn -Dflyway.configFileEncoding=ISO-8859-1 flyway:migrate

This is also possible via the configuration section of the plugin or Maven properties, as described above.

Alternatively you can also use the FLYWAY_CONFIG_FILE_ENCODING environment variable for this. When set it will take preference over the command-line parameter.


Overriding order

The Flyway Maven plugin has been carefully designed to load and override configuration in a sensible order.

Settings are loaded in the following order (higher items in the list take precedence over lower ones):

  1. System properties
  2. Environment variables
  3. Custom config files
  4. Maven properties
  5. Plugin configuration section
  6. Credentials from settings.xml
  7. <user-home>/flyway.conf
  8. Flyway Maven plugin defaults

The means that if for example flyway.url is both present in a config file and passed as -Dflyway.url= from the command-line, the JVM system property passed in via the command-line will take precedence and be used.

Didn't find what you were looking for?