Share your experience with Database DevOps by taking part in the 2021 State of Database DevOps survey Take the survey

Maven Goal: Clean

Drops all objects (tables, views, procedures, triggers, …) in the configured schemas.
The schemas are cleaned in the order specified by the schemas property.


Default Phase

  • pre-integration-test


> mvn flyway:clean


Parameter Required Default Description
url YES The jdbc url to use to connect to the database
driver NO Auto-detected based on url The fully qualified classname of the jdbc driver to use to connect to the database
serverId NO flyway-db The id of the server in the Maven settings.xml file to load the credentials from.

This is an alternative to passing the credentials in directly through properties.
user NO The user to use to connect to the database
password NO The password to use to connect to the database
connectRetries NO 0 The maximum number of retries when attempting to connect to the database. After each failed attempt, Flyway will wait 1 second before attempting to connect again, up to the maximum number of times specified by connectRetries.
initSql NO none The SQL statements to run to initialize a new database connection immediately after opening it.
defaultSchema NO The default schema for the database connection The default schema managed by Flyway. This schema name is case-sensitive.


  • This schema will be automatically set as the default one during the migration.
  • This schema will also be the one containing the schema history table.
  • If this schema is not specified then it will default to the first member of schemas.
schemas NO The default schema for the database connection Comma-separated list of schemas managed by Flyway. These schema names are case-sensitive.


  • Flyway will automatically attempt to create all these schemas, unless the first one already exists.
  • The schemas will be cleaned in the order of this list.
  • If Flyway created them, the schemas themselves will as be dropped when cleaning.
  • defaultSchema will default to the first member of this list if not explicitly specified.
Read more about Flyway support for multiple schemas in our FAQs
callbacks NO Fully qualified class names of Callback implementations to use to hook into the Flyway lifecycle.
skipDefaultCallbacks NO false Whether default built-in callbacks (sql) should be skipped. If true, only custom callbacks are used.
cleanDisabled NO false Whether to disable clean. This is especially useful for production environments where running clean can be quite a career limiting move.
skip NO false Skips the execution of the plugin for this module
configFiles NO Additional files from which to load the Flyway configuration. The names of the individual properties match the ones you would use as Maven or System properties. The encoding of the file must be the same as the encoding defined with the flyway.encoding property, which is UTF-8 by default. Relative paths are relative to `workingDirectory`.
workingDirectory NO project.basedir (where the POM resides) The working directory to consider when dealing with relative paths for both config files and locations.
validateMigrationNaming NO false Whether to ignore migration files whose names do not match the naming conventions.

If false, files with invalid names are ignored and Flyway continues normally. If true, Flyway fails fast and lists the offending files.
licenseKey NO none Your Flyway license key (FL01...). Not yet a Flyway Pro or Enterprise Edition customer? Request your Flyway trial license key to try out Flyway Pro and Enterprise Edition features free for 30 days.

Sample configuration

    <initSql>SET ROLE 'myuser'</initSql>

Sample output

> mvn flyway:clean

[INFO] [flyway:clean {execution: default-cli}]
[INFO] Cleaned database schema 'PUBLIC' (execution time 00:00.016s)

Maven: info