The Flyway command-line tool, Maven plugin and
Gradle plugin support loading configuration via environment variables.
This also possible using the Flyway API by calling the envVars()
method on the configuration.
The following environment variables are supported:
Environment Variable | Description |
---|---|
FLYWAY_EDITION | The edition of Flyway to use. Must be one of community ,
pro or enterprise . Only applies to the Flyway command-line. This
option is not settable via configuration files. |
FLYWAY_CONFIG_FILES | Comma-separated list of configuration files to load |
FLYWAY_CONFIG_FILE_ENCODING | The encoding to use when loading configuration files |
FLYWAY_URL | The jdbc url to use to connect to the database |
FLYWAY_DRIVER | The fully qualified classname of the JDBC driver to use to connect to the database |
FLYWAY_USER | The user to use to connect to the database |
FLYWAY_PASSWORD | The password to use to connect to the database |
FLYWAY_CONNECT_RETRIES | 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. |
FLYWAY_INIT_SQL | The SQL statements to run to initialize a new database connection immediately after opening it. |
FLYWAY_DEFAULT_SCHEMA | The default schema managed by Flyway. This schema will be the one containing the schema history table.
This schema will also be the default for the database connection (provided the database supports this concept).
If not specified, but FLYWAY_SCHEMAS is, the default schema is the first in that list. |
FLYWAY_SCHEMAS | Comma-separated case-sensitive list of schemas managed by Flyway. Flyway will attempt to create these
schemas if they do not already exist, and will clean them in the order of this list. If Flyway created
them, then the schemas themselves will be dropped when cleaning. If the default schema is not specified, the first is this list also acts as default schema. |
FLYWAY_CREATE_SCHEMAS | Whether Flyway should attempt to create the schemas specified in the schemas property |
FLYWAY_TABLE | The name of Flyway's schema history table. By default (single-schema mode) the schema history table is placed in the default schema for the connection provided by the datasource. When the flyway.schemas property is set (multi-schema mode), the schema history table is placed in the first schema of the list. |
FLYWAY_TABLESPACE | The tablespace where to create the schema history table that will be used by Flyway. This setting is only relevant for databases that do support the notion of tablespaces. Its value is simply ignored for all others. |
FLYWAY_LOCATIONS | Comma-separated list of locations to scan recursively for migrations. The location type is determined by its prefix. Unprefixed locations or locations starting with classpath: point to a package on the
classpath and may contain both SQL and Java-based migrations.Locations starting with filesystem: point to a directory on the filesystem, may only
contain SQL migrations and are only scanned recursively down non-hidden directories.Locations can contain wildcards. This allows matching against a path pattern instead of a single path. Supported wildcards:
|
FLYWAY_JAR_DIRS | Comma-separated list of directories containing JDBC drivers and Java-based migrations |
FLYWAY_SQL_MIGRATION_PREFIX | The file name prefix for versioned SQL migrations. Versioned SQL migrations have the following file name structure: prefixVERSIONseparatorDESCRIPTIONsuffix , which using the defaults translates to V1.1__My_description.sql |
FLYWAY_UNDO_SQL_MIGRATION_PREFIX Flyway Teams | The file name prefix for undo SQL migrations. Undo SQL migrations are responsible for undoing the effects of the versioned migration with the same version. They have the following file name structure: prefixVERSIONseparatorDESCRIPTIONsuffix , which using the defaults translates to U1.1__My_description.sql |
FLYWAY_REPEATABLE_SQL_MIGRATION_PREFIX | The file name prefix for repeatable SQL migrations. Repeatable SQL migrations have the following file name structure: prefixSeparatorDESCRIPTIONsuffix , which using the defaults translates to R__My_description.sql |
FLYWAY_SQL_MIGRATION_SEPARATOR | The file name separator for Sql migrations |
FLYWAY_SQL_MIGRATION_SUFFIXES | Comma-separated list of file name suffixes for SQL migrations. SQL migrations have the following file name structure: prefixVERSIONseparatorDESCRIPTIONsuffix , which using the defaults translates to V1_1__My_description.sql Multiple suffixes (like .sql,.pkg,.pkb) can be specified for easier compatibility with other tools such as editors with specific file associations. |
FLYWAY_STREAM Flyway Teams | Whether to stream SQL migrations when executing them. Streaming doesn't load the entire migration in memory at once. Instead each statement is loaded individually. This is particularly useful for very large SQL migrations composed of multiple MB or even GB of reference data, as this dramatically reduces Flyway's memory consumption. |
FLYWAY_BATCH Flyway Teams | Whether to batch SQL statements when executing them. Batching can save up to 99 percent of network roundtrips by sending up to 100 statements at once over the network to the database, instead of sending each statement individually. This is particularly useful for very large SQL migrations composed of multiple MB or even GB of reference data, as this can dramatically reduce the network overhead. This is supported for INSERT, UPDATE, DELETE, MERGE and UPSERT statements. All other statements are automatically executed without batching. |
FLYWAY_MIXED | Whether to allow mixing transactional and non-transactional statements within the same migration. Enabling this automatically causes the entire affected migration to be run without a transaction. Note that this is only applicable for PostgreSQL, Aurora PostgreSQL, SQL Server and SQLite which all have statements that do not run at all within a transaction. This is not to be confused with implicit transaction, as they occur in MySQL or Oracle, where even though a DDL statement was run within within a transaction, the database will issue an implicit commit before and after its execution. |
FLYWAY_GROUP | Whether to group all pending migrations together in the same transaction when applying them (only recommended for databases with support for DDL transactions) |
FLYWAY_ENCODING | The encoding of Sql migrations |
FLYWAY_PLACEHOLDER_REPLACEMENT | Whether placeholders should be replaced |
FLYWAY_PLACEHOLDERS_<NAME> | Placeholders to replace in SQL migrations. For example to replace a placeholder named key1
with the value value1 , you can set the environment variable FLYWAY_PLACEHOLDERS_KEY1
to value1 . Flyway will then convert the KEY1 part to lowercase (key1 ) and look for it, in
conjunction with the placeholder prefix and suffix, in your SQL migrations. Flyway will then
replace any occurances it finds with value1 . |
FLYWAY_PLACEHOLDER_PREFIX | The prefix of every placeholder |
FLYWAY_PLACEHOLDER_SUFFIX | The suffix of every placeholder |
FLYWAY_RESOLVERS | Comma-separated list of fully qualified class names of custom MigrationResolver implementations to be used in addition to the built-in ones for resolving Migrations to apply. |
FLYWAY_SKIP_DEFAULT_RESOLVERS | Whether default built-in resolvers (sql, jdbc and spring-jdbc) should be skipped. If true, only custom resolvers are used. |
FLYWAY_CALLBACKS | Comma-separated list of fully qualified class names of Callback implementations to use to hook into the Flyway lifecycle. |
FLYWAY_SKIP_DEFAULT_CALLBACKS | Whether default built-in callbacks (sql) should be skipped. If true, only custom callbacks are used. |
FLYWAY_TARGET | The target version up to which Flyway should consider migrations. Migrations with a higher version number will be ignored. Special values:
|
FLYWAY_OUTPUT_QUERY_RESULTS | Controls whether Flyway should output a table with the results of queries when executing migrations. |
FLYWAY_OUT_OF_ORDER | Allows migrations to be run "out of order".
If you already have versions 1 and 3 applied, and now a version 2 is found, it will be applied too instead of being ignored. |
FLYWAY_VALIDATE_ON_MIGRATE | Whether to automatically call validate or not when running migrate. For each sql migration a CRC32 checksum is calculated when the sql script is executed. The validate mechanism checks if the sql migration in the classpath still has the same checksum as the sql migration already executed in the database. |
FLYWAY_CLEAN_ON_VALIDATION_ERROR | Whether to automatically call clean or not when a validation error occurs. This is exclusively intended as a convenience for development. Even though we strongly recommend not to change migration scripts once they have been checked into SCM and run, this provides a way of dealing with this case in a smooth manner. The database will be wiped clean automatically, ensuring that the next migration will bring you back to the state checked into SCM. Warning ! Do not enable in production ! |
FLYWAY_IGNORE_MISSING_MIGRATIONS | Ignore missing migrations when reading the schema history table. These are migrations that were performed by an older deployment of the application that are no longer available in this version. For example: we have migrations available on the classpath with versions 1.0 and 3.0. The schema history table indicates that a migration with version 2.0 (unknown to us) has also been applied. Instead of bombing out (fail fast) with an exception, a warning is logged and Flyway continues normally. This is useful for situations where one must be able to deploy a newer version of the application even though it doesn't contain migrations included with an older one anymore. |
FLYWAY_IGNORE_IGNORED_MIGRATIONS | Ignore ignored migrations when reading the schema history table. These are migrations that were added in between already migrated migrations in this version. For example: we have migrations available on the classpath with versions from 1.0 to 3.0. The schema history table indicates that version 1 was finished on 1.0.15, and the next one was 2.0.0. But with the next release a new migration was added to version 1: 1.0.16. Such scenario is ignored by migrate command, but by default is rejected by validate. When ignoreIgnoredMigrations is enabled, such case will not be reported by validate command. This is useful for situations where one must be able to deliver complete set of migrations in a delivery package for multiple versions of the product, and allows for further development of older versions. |
FLYWAY_IGNORE_PENDING_MIGRATIONS | Ignore pending migrations when reading the schema history table. These are migrations that are available but have not yet been applied. This can be useful for verifying that in-development migration changes don't contain any validation-breaking changes of migrations that have already been applied to a production environment, e.g. as part of a CI/CD process, without failing because of the existence of new migration versions. |
FLYWAY_IGNORE_FUTURE_MIGRATIONS | Ignore future migrations when reading the schema history table. These are migrations that were performed by a newer deployment of the application that are not yet available in this version. For example: we have migrations available on the classpath up to version 3.0. The schema history table indicates that a migration to version 4.0 (unknown to us) has already been applied. Instead of bombing out (fail fast) with an exception, a warning is logged and Flyway continues normally. This is useful for situations where one must be able to redeploy an older version of the application after the database has been migrated by a newer one. |
FLYWAY_CLEAN_DISABLED | Whether to disable clean. This is especially useful for production environments where running clean can be quite a career limiting move. |
FLYWAY_BASELINE_ON_MIGRATE | Whether to automatically call baseline when migrate is executed against a non-empty schema with no metadata
table.
This schema will then be baselined with the baselineVersion before executing the migrations.
Only migrations above baselineVersion will then be applied.This is useful for initial Flyway production deployments on projects with an existing DB. Be careful when enabling this as it removes the safety net that ensures Flyway does not migrate the wrong database in case of a configuration mistake! |
FLYWAY_BASELINE_VERSION | The version to tag an existing schema with when executing baseline |
FLYWAY_BASELINE_DESCRIPTION | The description to tag an existing schema with when executing baseline |
FLYWAY_INSTALLED_BY | The username that will be recorded in the schema history table as having applied the migration |
FLYWAY_ERROR_OVERRIDES Flyway Teams | Comma-sparated list of rules for the built-in error handler that let you override specific SQL states and errors codes in order to force specific errors or warnings to be treated as debug messages, info messages, warnings or errors.
Each error override has the following format: The following behaviors are accepted:
Example 1: to force Oracle stored procedure compilation issues to produce errors instead of warnings, the following errorOverride can be used: Example 2: to force SQL Server PRINT messages to be displayed as info messages (without SQL state and error code details) instead of warnings, the following errorOverride can be used: Example 3: to force all errors with SQL error code 123 to be treated as warnings instead, the following errorOverride can be used: |
FLYWAY_DRYRUN_OUTPUT Flyway Teams | The file where to output the SQL statements of a migration dry run. If the file specified is in a non-existent directory, Flyway will create all directories and parent directories as needed. Omit to use the default mode of executing the SQL statements directly against the database. |
FLYWAY_ORACLE_SQLPLUS Flyway Teams | Enable Flyway's support for Oracle SQL*Plus commands |
FLYWAY_ORACLE_SQLPLUS_WARN Flyway Teams | Whether Flyway should issue a warning instead of an error whenever it encounters an Oracle SQL*Plus statement it doesn't yet support. |
FLYWAY_LICENSE_KEY Flyway Teams | 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. |