|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.googlecode.flyway.core.Flyway
public class Flyway
This is the centre point of Flyway, and for most users, the only class they will ever have to deal with.
It is THE public API from which all important Flyway functions such as clean, validate and migrate can be called.
| Constructor Summary | |
|---|---|
Flyway()
Creates a new instance of Flyway. |
|
| Method Summary | |
|---|---|
void |
clean()
Drops all objects (tables, views, procedures, triggers, ...) in the configured schemas. |
void |
configure(Properties properties)
Configures Flyway with these properties. |
String |
getBaseDir()
Deprecated. Uses getLocations instead. Will be removed in Flyway 3.0. |
String |
getBasePackage()
Deprecated. Uses getLocations instead. Will be removed in Flyway 3.0. |
DataSource |
getDataSource()
Retrieves the dataSource to use to access the database. |
String |
getEncoding()
Retrieves the encoding of Sql migrations. |
String |
getInitialDescription()
Retrieves the description of the initial version. |
MigrationVersion |
getInitialVersion()
Retrieves the initial version to put in the database. |
String[] |
getLocations()
Retrieves locations on the classpath to scan recursively for migrations. |
String |
getPlaceholderPrefix()
Retrieves the prefix of every placeholder. |
Map<String,String> |
getPlaceholders()
Retrieves the map of <placeholder, replacementValue> to apply to sql migration scripts. |
String |
getPlaceholderSuffix()
Retrieves the suffix of every placeholder. |
String[] |
getSchemas()
Retrieves the schemas managed by Flyway. |
String |
getSqlMigrationPrefix()
Retrieves the file name prefix for sql migrations. |
String |
getSqlMigrationSuffix()
Retrieves the file name suffix for sql migrations. |
String |
getTable()
Retrieves the name of the schema metadata table that will be used by Flyway. |
MigrationVersion |
getTarget()
Retrieves the target version up to which Flyway should run migrations. |
com.googlecode.flyway.core.validation.ValidationErrorMode |
getValidationErrorMode()
Deprecated. Use isCleanOnValidationError instead. Will be removed in Flyway 3.0. |
com.googlecode.flyway.core.validation.ValidationMode |
getValidationMode()
Deprecated. Use isValidateOnMigrate instead. Will be removed in Flyway 3.0. |
List<com.googlecode.flyway.core.metadatatable.MetaDataTableRow> |
history()
Deprecated. Use flyway.info().applied() instead. Will be removed in Flyway 3.0. |
MigrationInfoService |
info()
Retrieves the complete information about all the migrations including applied, pending and current migrations with details and status. |
void |
init()
Creates and initializes the Flyway metadata table. |
boolean |
isCleanOnValidationError()
Whether to automatically call clean or not when a validation error occurs. |
boolean |
isDisableInitCheck()
Deprecated. Use initOnMigrate instead. Will be removed in Flyway 3.0. |
boolean |
isIgnoreFailedFutureMigration()
Whether to ignore failed future migrations when reading the metadata table. |
boolean |
isInitOnMigrate()
Whether to automatically call init when migrate is executed against a non-empty schema with no metadata table. |
boolean |
isOutOfOrder()
Allows migrations to be run "out of order". |
boolean |
isValidateOnMigrate()
Whether to automatically call validate or not when running migrate. |
int |
migrate()
Starts the database migration. |
void |
repair()
Repairs the Flyway metadata table after a failed migration. |
void |
setBaseDir(String baseDir)
Deprecated. Use setLocations instead. Will be removed in Flyway 3.0. |
void |
setBasePackage(String basePackage)
Deprecated. Use setLocations instead. Will be removed in Flyway 3.0. |
void |
setCleanOnValidationError(boolean cleanOnValidationError)
Whether to automatically call clean or not when a validation error occurs. |
void |
setDataSource(DataSource dataSource)
Sets the datasource to use. |
void |
setDisableInitCheck(boolean disableInitCheck)
Deprecated. Use initOnMigrate instead. Will be removed in Flyway 3.0. |
void |
setEncoding(String encoding)
Sets the encoding of Sql migrations. |
void |
setIgnoreFailedFutureMigration(boolean ignoreFailedFutureMigration)
Ignores failed future migrations when reading the metadata table. |
void |
setInitialDescription(String initialDescription)
The description of the initial version. |
void |
setInitialVersion(MigrationVersion initialVersion)
The initial version to put in the database. |
void |
setInitialVersion(com.googlecode.flyway.core.migration.SchemaVersion initialVersion)
Deprecated. Use setInitialVersion(MigrationVersion) instead. Will be removed in Flyway 3.0. |
void |
setInitialVersion(String initialVersion)
The initial version to put in the database. |
void |
setInitOnMigrate(boolean initOnMigrate)
Whether to automatically call init when migrate is executed against a non-empty schema with no metadata table. |
void |
setLocations(String... locations)
Sets the locations on the classpath to scan recursively for migrations. |
void |
setOutOfOrder(boolean outOfOrder)
Allows migrations to be run "out of order". |
void |
setPlaceholderPrefix(String placeholderPrefix)
Sets the prefix of every placeholder. |
void |
setPlaceholders(Map<String,String> placeholders)
Sets the placeholders to replace in sql migration scripts. |
void |
setPlaceholderSuffix(String placeholderSuffix)
Sets the suffix of every placeholder. |
void |
setSchemas(String... schemas)
Sets the schemas managed by Flyway. |
void |
setSqlMigrationPrefix(String sqlMigrationPrefix)
Sets the file name prefix for sql migrations. |
void |
setSqlMigrationSuffix(String sqlMigrationSuffix)
Sets the file name suffix for sql migrations. |
void |
setTable(String table)
Sets the name of the schema metadata table that will be used by Flyway. |
void |
setTarget(MigrationVersion target)
Sets the target version up to which Flyway should run migrations. |
void |
setTarget(com.googlecode.flyway.core.migration.SchemaVersion target)
Deprecated. Use setTarget(MigrationVersion) instead. Will be removed in Flyway 3.0. |
void |
setTarget(String target)
Sets the target version up to which Flyway should run migrations. |
void |
setValidateOnMigrate(boolean validateOnMigrate)
Whether to automatically call validate or not when running migrate. |
void |
setValidationErrorMode(com.googlecode.flyway.core.validation.ValidationErrorMode validationErrorMode)
Deprecated. Use setCleanOnValidationError instead. Will be removed in Flyway 3.0. |
void |
setValidationMode(com.googlecode.flyway.core.validation.ValidationMode validationMode)
Deprecated. Use setValidateOnMigrate instead. Will be removed in Flyway 3.0. |
com.googlecode.flyway.core.metadatatable.MetaDataTableRow |
status()
Deprecated. Use flyway.info().current() instead. Will be removed in Flyway 3.0. |
void |
validate()
Validate applied migration with classpath migrations to detect accidental changes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Flyway()
| Method Detail |
|---|
public String[] getLocations()
@Deprecated public String getBasePackage()
@Deprecated public String getBaseDir()
public String getEncoding()
public String[] getSchemas()
public String getTable()
Retrieves the name of the schema metadata table that will be used by Flyway.
By default (single-schema mode) the metadata 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 metadata table is placed in the first schema of the list.
public MigrationVersion getTarget()
public Map<String,String> getPlaceholders()
public String getPlaceholderPrefix()
public String getPlaceholderSuffix()
public String getSqlMigrationPrefix()
public String getSqlMigrationSuffix()
public boolean isIgnoreFailedFutureMigration()
true to terminate normally and log a warning, false to fail fast with an exception.
(default: false)@Deprecated public com.googlecode.flyway.core.validation.ValidationMode getValidationMode()
@Deprecated public com.googlecode.flyway.core.validation.ValidationErrorMode getValidationErrorMode()
public boolean isValidateOnMigrate()
true if validate should be called. false if not. (default: false)public boolean isCleanOnValidationError()
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 !
true if clean should be called. false if not. (default: false)public MigrationVersion getInitialVersion()
public String getInitialDescription()
@Deprecated public boolean isDisableInitCheck()
true if the check is disabled. false if it is active. (default: false)public boolean isInitOnMigrate()
Whether to automatically call init when migrate is executed against a non-empty schema with no metadata table.
This schema will then be initialized with the initialVersion before executing the migrations.
Only migrations above initialVersion 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!
true if init should be called on migrate for non-empty schemas, false if not. (default: false)public boolean isOutOfOrder()
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.
true if outOfOrder migrations should be applied, false if not. (default: false)public DataSource getDataSource()
public void setIgnoreFailedFutureMigration(boolean ignoreFailedFutureMigration)
ignoreFailedFutureMigration - true to terminate normally and log a warning, false to fail
fast with an exception. (default: false)@Deprecated public void setValidationMode(com.googlecode.flyway.core.validation.ValidationMode validationMode)
validationMode - The mode for validation. (default: NONE)@Deprecated public void setValidationErrorMode(com.googlecode.flyway.core.validation.ValidationErrorMode validationErrorMode)
validationErrorMode - The error mode for validation. (default: FAIL)public void setValidateOnMigrate(boolean validateOnMigrate)
validateOnMigrate - true if validate should be called. false if not. (default: false)public void setCleanOnValidationError(boolean cleanOnValidationError)
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 !
cleanOnValidationError - true if clean should be called. false if not. (default: false)public void setLocations(String... locations)
locations - Locations on the classpath to scan recursively for migrations. Locations may contain both sql
and java-based migrations. (default: db/migration)@Deprecated public void setBasePackage(String basePackage)
basePackage - The base package where the migrations are located. (default: db.migration)@Deprecated public void setBaseDir(String baseDir)
baseDir - The base directory on the classpath where the Sql migrations are located. (default: db/migration)public void setEncoding(String encoding)
encoding - The encoding of Sql migrations. (default: UTF-8)public void setSchemas(String... schemas)
schemas - The schemas managed by Flyway. May not be null. Must contain at least one element.public void setTable(String table)
Sets the name of the schema metadata table that will be used by Flyway.
By default (single-schema mode) the metadata 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 metadata table is placed in the first schema of the list.
table - The name of the schema metadata table that will be used by flyway. (default: schema_version)@Deprecated public void setTarget(com.googlecode.flyway.core.migration.SchemaVersion target)
target - The target version up to which Flyway should run migrations. Migrations with a higher version
number will not be applied. (default: the latest version)public void setTarget(MigrationVersion target)
target - The target version up to which Flyway should run migrations. Migrations with a higher version
number will not be applied. (default: the latest version)public void setTarget(String target)
target - The target version up to which Flyway should run migrations. Migrations with a higher version
number will not be applied. (default: the latest version)public void setPlaceholders(Map<String,String> placeholders)
placeholders - The map of <placeholder, replacementValue> to apply to sql migration scripts.public void setPlaceholderPrefix(String placeholderPrefix)
placeholderPrefix - The prefix of every placeholder. (default: ${ )public void setPlaceholderSuffix(String placeholderSuffix)
placeholderSuffix - The suffix of every placeholder. (default: } )public void setSqlMigrationPrefix(String sqlMigrationPrefix)
sqlMigrationPrefix - The file name prefix for sql migrations (default: V)public void setSqlMigrationSuffix(String sqlMigrationSuffix)
sqlMigrationSuffix - The file name suffix for sql migrations (default: .sql)public void setDataSource(DataSource dataSource)
dataSource - The datasource to use. Must have the necessary privileges to execute ddl.@Deprecated public void setInitialVersion(com.googlecode.flyway.core.migration.SchemaVersion initialVersion)
initialVersion - The initial version to put in the database. (default: 0)public void setInitialVersion(MigrationVersion initialVersion)
initialVersion - The initial version to put in the database. (default: 0)public void setInitialVersion(String initialVersion)
initialVersion - The initial version to put in the database. (default: 0)public void setInitialDescription(String initialDescription)
initialDescription - The description of the initial version. (default: << Flyway Init >>)@Deprecated public void setDisableInitCheck(boolean disableInitCheck)
disableInitCheck - true if the check is disabled. false if it is active. (default: false)public void setInitOnMigrate(boolean initOnMigrate)
Whether to automatically call init when migrate is executed against a non-empty schema with no metadata table.
This schema will then be initialized with the initialVersion before executing the migrations.
Only migrations above initialVersion 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!
initOnMigrate - true if init should be called on migrate for non-empty schemas, false if not. (default: false)public void setOutOfOrder(boolean outOfOrder)
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.
outOfOrder - true if outOfOrder migrations should be applied, false if not. (default: false)
public int migrate()
throws FlywayException
FlywayException - when the migration failed.
public void validate()
throws FlywayException
FlywayException - when the validation failed.public void clean()
FlywayException - when the clean fails.@Deprecated public com.googlecode.flyway.core.metadatatable.MetaDataTableRow status()
null if no migration has been applied yet.@Deprecated public List<com.googlecode.flyway.core.metadatatable.MetaDataTableRow> history()
public MigrationInfoService info()
FlywayException - when the info retrieval failed.
public void init()
throws FlywayException
FlywayException - when the schema initialization failed.
public void repair()
throws FlywayException
FlywayException - when the metadata table repair failed.public void configure(Properties properties)
properties - Properties used for configuration.
FlywayException - when the configuration failed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||