Interface Configuration
-
- All Known Subinterfaces:
FlywayConfiguration
- All Known Implementing Classes:
ClassicConfiguration,FluentConfiguration,Flyway
public interface ConfigurationFlyway configuration.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description StringgetBaselineDescription()Retrieves the description to tag an existing schema with when executing baseline.MigrationVersiongetBaselineVersion()Retrieves the version to tag an existing schema with when executing baseline.Callback[]getCallbacks()Gets the callbacks for lifecycle notifications.ClassLoadergetClassLoader()Retrieves the ClassLoader to use for loading migrations, resolvers, etc from the classpath.intgetConnectRetries()The maximum number of retries when attempting to connect to the database.DataSourcegetDataSource()Retrieves the dataSource to use to access the database.OutputStreamgetDryRunOutput()The stream where to output the SQL statements of a migration dry run.CharsetgetEncoding()Retrieves the encoding of Sql migrations.ErrorHandler[]getErrorHandlers()Deprecated.ErrorHandlers have been deprecated and will be removed in Flyway 6.0 use statement-level callbacks instead.String[]getErrorOverrides()Rules for the built-in error handler that lets you override specific SQL states and errors codes from error to warning or from warning to error.StringgetInitSql()The SQL statements to run to initialize a new database connection immediately after opening it.StringgetInstalledBy()The username that will be recorded in the schema history table as having applied the migration.StringgetLicenseKey()Flyway's license key.Location[]getLocations()Retrieves the locations to scan recursively for migrations.StringgetPlaceholderPrefix()Retrieves the prefix of every placeholder.Map<String,String>getPlaceholders()Retrieves the map of <placeholder, replacementValue> to apply to sql migration scripts.StringgetPlaceholderSuffix()Retrieves the suffix of every placeholder.StringgetRepeatableSqlMigrationPrefix()Retrieves the file name prefix for repeatable SQL migrations.MigrationResolver[]getResolvers()Retrieves the The custom MigrationResolvers to be used in addition to the built-in ones for resolving Migrations to apply.String[]getSchemas()Retrieves the schemas managed by Flyway.StringgetSqlMigrationPrefix()The file name prefix for versioned SQL migrations.StringgetSqlMigrationSeparator()Retrieves the file name separator for sql migrations.String[]getSqlMigrationSuffixes()The file name suffixes for SQL migrations.StringgetTable()Retrieves the name of the schema schema history table that will be used by Flyway.MigrationVersiongetTarget()Retrieves the target version up to which Flyway should consider migrations.StringgetUndoSqlMigrationPrefix()The file name prefix for undo SQL migrations.booleanisBaselineOnMigrate()Whether to automatically call baseline when migrate is executed against a non-empty schema with no schema history table.booleanisBatch()Whether to batch SQL statements when executing them.booleanisCleanDisabled()Whether to disable clean.booleanisCleanOnValidationError()Whether to automatically call clean or not when a validation error occurs.booleanisGroup()Whether to group all pending migrations together in the same transaction when applying them (only recommended for databases with support for DDL transactions).booleanisIgnoreFutureMigrations()Ignore future migrations when reading the schema history table.booleanisIgnoreIgnoredMigrations()Ignore ignored migrations when reading the schema history table.booleanisIgnoreMissingMigrations()Ignore missing migrations when reading the schema history table.booleanisIgnorePendingMigrations()Ignore pending migrations when reading the schema history table.booleanisMixed()Whether to allow mixing transactional and non-transactional statements within the same migration.booleanisOracleSqlplus()Whether to Flyway's support for Oracle SQL*Plus commands should be activated.booleanisOutOfOrder()Allows migrations to be run "out of order".booleanisPlaceholderReplacement()Checks whether placeholders should be replaced.booleanisSkipDefaultCallbacks()Whether Flyway should skip the default callbacks.booleanisSkipDefaultResolvers()Whether Flyway should skip the default resolvers.booleanisStream()Whether to stream SQL migrations when executing them.booleanisValidateOnMigrate()Whether to automatically call validate or not when running migrate.
-
-
-
Method Detail
-
getClassLoader
ClassLoader getClassLoader()
Retrieves the ClassLoader to use for loading migrations, resolvers, etc from the classpath.- Returns:
- The ClassLoader to use for loading migrations, resolvers, etc from the classpath. (default: Thread.currentThread().getContextClassLoader() )
-
getDataSource
DataSource getDataSource()
Retrieves the dataSource to use to access the database. Must have the necessary privileges to execute ddl.- Returns:
- The dataSource to use to access the database. Must have the necessary privileges to execute ddl.
-
getConnectRetries
int getConnectRetries()
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.- Returns:
- The maximum number of retries when attempting to connect to the database. (default: 0)
-
getInitSql
String getInitSql()
The SQL statements to run to initialize a new database connection immediately after opening it.- Returns:
- The SQL statements. (default:
null)
-
getBaselineVersion
MigrationVersion getBaselineVersion()
Retrieves the version to tag an existing schema with when executing baseline.- Returns:
- The version to tag an existing schema with when executing baseline. (default: 1)
-
getBaselineDescription
String getBaselineDescription()
Retrieves the description to tag an existing schema with when executing baseline.- Returns:
- The description to tag an existing schema with when executing baseline. (default: << Flyway Baseline >>)
-
getResolvers
MigrationResolver[] getResolvers()
Retrieves the The custom MigrationResolvers to be used in addition to the built-in ones for resolving Migrations to apply.- Returns:
- The custom MigrationResolvers to be used in addition to the built-in ones for resolving Migrations to apply. An empty array if none. (default: none)
-
isSkipDefaultResolvers
boolean isSkipDefaultResolvers()
Whether Flyway should skip the default resolvers. If true, only custom resolvers are used.- Returns:
- Whether default built-in resolvers should be skipped. (default: false)
-
getCallbacks
Callback[] getCallbacks()
Gets the callbacks for lifecycle notifications.- Returns:
- The callbacks for lifecycle notifications. An empty array if none. (default: none)
-
isSkipDefaultCallbacks
boolean isSkipDefaultCallbacks()
Whether Flyway should skip the default callbacks. If true, only custom callbacks are used.- Returns:
- Whether default built-in callbacks should be skipped. (default: false)
-
getSqlMigrationPrefix
String getSqlMigrationPrefix()
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
- Returns:
- The file name prefix for sql migrations. (default: V)
-
getUndoSqlMigrationPrefix
String getUndoSqlMigrationPrefix()
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 Pro and Flyway Enterprise only
- Returns:
- The file name prefix for undo sql migrations. (default: U)
-
getRepeatableSqlMigrationPrefix
String getRepeatableSqlMigrationPrefix()
Retrieves 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
- Returns:
- The file name prefix for repeatable sql migrations. (default: R)
-
getSqlMigrationSeparator
String getSqlMigrationSeparator()
Retrieves the file name separator for sql migrations.Sql migrations have the following file name structure: prefixVERSIONseparatorDESCRIPTIONsuffix , which using the defaults translates to V1_1__My_description.sql
- Returns:
- The file name separator for sql migrations. (default: __)
-
getSqlMigrationSuffixes
String[] getSqlMigrationSuffixes()
The file name suffixes for SQL migrations. (default: .sql)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.
- Returns:
- The file name suffixes for SQL migrations.
-
isPlaceholderReplacement
boolean isPlaceholderReplacement()
Checks whether placeholders should be replaced.- Returns:
- Whether placeholders should be replaced. (default: true)
-
getPlaceholderSuffix
String getPlaceholderSuffix()
Retrieves the suffix of every placeholder.- Returns:
- The suffix of every placeholder. (default: } )
-
getPlaceholderPrefix
String getPlaceholderPrefix()
Retrieves the prefix of every placeholder.- Returns:
- The prefix of every placeholder. (default: ${ )
-
getPlaceholders
Map<String,String> getPlaceholders()
Retrieves the map of <placeholder, replacementValue> to apply to sql migration scripts.- Returns:
- The map of <placeholder, replacementValue> to apply to sql migration scripts.
-
getTarget
MigrationVersion getTarget()
Retrieves the target version up to which Flyway should consider migrations. Migrations with a higher version number will be ignored. The special valuecurrentdesignates the current version of the schema.- Returns:
- The target version up to which Flyway should consider migrations. (default: the latest version)
-
getTable
String getTable()
Retrieves the name of the schema schema history table that will be used by Flyway.
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.
- Returns:
- The name of the schema schema history table that will be used by flyway. (default: flyway_schema_history)
-
getSchemas
String[] getSchemas()
Retrieves the schemas managed by Flyway. These schema names are case-sensitive.Consequences:
- Flyway will automatically attempt to create all these schemas, unless the first one already exists.
- The first schema in the list will be automatically set as the default one during the migration.
- The first schema in the list will also be the one containing the schema history table.
- The schemas will be cleaned in the order of this list.
- If Flyway created them, the schemas themselves will as be dropped when cleaning.
- Returns:
- The schemas managed by Flyway. (default: The default schema for the database connection)
-
getEncoding
Charset getEncoding()
Retrieves the encoding of Sql migrations.- Returns:
- The encoding of Sql migrations. (default: UTF-8)
-
getLocations
Location[] getLocations()
Retrieves the 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 withfilesystem:point to a directory on the filesystem, may only contain SQL migrations and are only scanned recursively down non-hidden directories.- Returns:
- Locations to scan recursively for migrations. (default: classpath:db/migration)
-
isBaselineOnMigrate
boolean isBaselineOnMigrate()
Whether to automatically call baseline when migrate is executed against a non-empty schema with no schema history table. This schema will then be initialized with the
baselineVersionbefore executing the migrations. Only migrations abovebaselineVersionwill 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!
- Returns:
trueif baseline should be called on migrate for non-empty schemas,falseif not. (default:false)
-
isOutOfOrder
boolean isOutOfOrder()
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.
- Returns:
trueif outOfOrder migrations should be applied,falseif not. (default:false)
-
isIgnoreMissingMigrations
boolean isIgnoreMissingMigrations()
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. Note that if the most recently applied migration is removed, Flyway has no way to know it is missing and will mark it as future instead.- Returns:
trueto continue normally and log a warning,falseto fail fast with an exception. (default:false)
-
isIgnoreIgnoredMigrations
boolean isIgnoreIgnoredMigrations()
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.- Returns:
trueto continue normally,falseto fail fast with an exception. (default:false)
-
isIgnorePendingMigrations
boolean isIgnorePendingMigrations()
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.- Returns:
trueto continue normally,falseto fail fast with an exception. (default:false)
-
isIgnoreFutureMigrations
boolean isIgnoreFutureMigrations()
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.- Returns:
trueto continue normally and log a warning,falseto fail fast with an exception. (default:true)
-
isValidateOnMigrate
boolean isValidateOnMigrate()
Whether to automatically call validate or not when running migrate.- Returns:
trueif validate should be called.falseif not. (default:true)
-
isCleanOnValidationError
boolean isCleanOnValidationError()
Whether to automatically call clean or not when a validation error occurs.This is exclusively intended as a convenience for development. Even tough 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 !
- Returns:
trueif clean should be called.falseif not. (default:false)
-
isCleanDisabled
boolean isCleanDisabled()
Whether to disable clean.This is especially useful for production environments where running clean can be quite a career limiting move.
- Returns:
trueto disabled clean.falseto leave it enabled. (default:false)
-
isMixed
boolean isMixed()
Whether to allow mixing transactional and non-transactional statements within the same migration.- Returns:
trueif mixed migrations should be allowed.falseif an error should be thrown instead. (default:false)
-
isGroup
boolean isGroup()
Whether to group all pending migrations together in the same transaction when applying them (only recommended for databases with support for DDL transactions).- Returns:
trueif migrations should be grouped.falseif they should be applied individually instead. (default:false)
-
getInstalledBy
String getInstalledBy()
The username that will be recorded in the schema history table as having applied the migration.- Returns:
- The username or
nullfor the current database user of the connection. (default:null).
-
getErrorHandlers
@Deprecated ErrorHandler[] getErrorHandlers()
Deprecated.ErrorHandlers have been deprecated and will be removed in Flyway 6.0 use statement-level callbacks instead.Handlers for errors and warnings that occur during a migration. This can be used to customize Flyway's behavior by for example throwing another runtime exception, outputting a warning or suppressing the error instead of throwing a FlywayException. ErrorHandlers are invoked in order until one reports to have successfully handled the errors or warnings. If none do, or if none are present, Flyway falls back to its default handling of errors and warnings.Flyway Pro and Flyway Enterprise only
- Returns:
- The ErrorHandlers or an empty array if the default internal handler should be used instead. (default: none)
-
getErrorOverrides
String[] getErrorOverrides()
Rules for the built-in error handler that lets you override specific SQL states and errors codes from error to warning or from warning to error.Each error override has the following format:
STATE:12345:W. It is a 5 character SQL state, a colon, the SQL error code, a colon and finally the desired behavior that should override the initial one. The following behaviors are accepted:Wto force a warning andEto force an error.For example, to force Oracle stored procedure compilation issues to produce errors instead of warnings, the following errorOverride can be used:
99999:17110:EFlyway Pro and Flyway Enterprise only
- Returns:
- The ErrorOverrides or an empty array if none are defined. (default: none)
-
getDryRunOutput
OutputStream getDryRunOutput()
The stream where to output the SQL statements of a migration dry run.nullif the SQL statements are executed against the database directly.Flyway Pro and Flyway Enterprise only
- Returns:
- The stream or
nullif the SQL statements are executed against the database directly.
-
isStream
boolean isStream()
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 Pro and Flyway Enterprise only
- Returns:
trueto stream SQL migrations.falseto fully loaded them in memory instead. (default:false)
-
isBatch
boolean isBatch()
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 Pro and Flyway Enterprise only
- Returns:
trueto batch SQL statements.falseto execute them individually instead. (default:false)
-
isOracleSqlplus
boolean isOracleSqlplus()
Whether to Flyway's support for Oracle SQL*Plus commands should be activated.Flyway Pro and Flyway Enterprise only
- Returns:
trueto active SQL*Plus support.falseto fail fast instead. (default:false)
-
getLicenseKey
String getLicenseKey()
Flyway's license key.Flyway Pro and Flyway Enterprise only
- Returns:
- The license key.
-
-