com.googlecode.flyway.ant
Class MigrateTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.googlecode.flyway.ant.AbstractFlywayTask
              extended by com.googlecode.flyway.ant.AbstractMigrationLoadingTask
                  extended by com.googlecode.flyway.ant.MigrateTask
All Implemented Interfaces:
Cloneable

public class MigrateTask
extends AbstractMigrationLoadingTask

Ant task that triggers the migration of the configured database to the latest version.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.googlecode.flyway.ant.AbstractMigrationLoadingTask
AbstractMigrationLoadingTask.LocationElement, AbstractMigrationLoadingTask.Locations, AbstractMigrationLoadingTask.PlaceholderElement, AbstractMigrationLoadingTask.PlaceholdersElement
 
Field Summary
 
Fields inherited from class com.googlecode.flyway.ant.AbstractFlywayTask
log
 
Fields inherited from class org.apache.tools.ant.Task
taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
MigrateTask()
           
 
Method Summary
protected  void doExecuteWithMigrationConfig(Flyway flyway)
          Executes Flyway fully configured for loading migrations.
 void setDisableInitCheck(boolean disableInitCheck)
          Deprecated. Use initOnMigrate instead. Will be removed in Flyway 3.0.
 void setIgnoreFailedFutureMigration(boolean ignoreFailedFutureMigration)
           
 void setInitOnMigrate(boolean initOnMigrate)
           Whether to automatically call init when migrate is executed against a non-empty schema with no metadata table.
 void setValidateOnMigrate(boolean validateOnMigrate)
           
 void setValidationMode(String validationMode)
          Deprecated. Use validateOnMigrate instead. Will be removed in Flyway 3.0.
 
Methods inherited from class com.googlecode.flyway.ant.AbstractMigrationLoadingTask
addConfiguredLocations, addConfiguredPlaceholder, addConfiguredPlaceholders, doExecute, setBaseDir, setBasePackage, setCleanOnValidationError, setEncoding, setOutOfOrder, setPlaceholderPrefix, setPlaceholderSuffix, setSqlMigrationPrefix, setSqlMigrationSuffix, setTarget, setValidationErrorMode
 
Methods inherited from class com.googlecode.flyway.ant.AbstractFlywayTask
execute, setClasspath, setClasspathref, setDriver, setPassword, setSchemas, setTable, setUrl, setUser, useValueIfPropertyNotSet, useValueIfPropertyNotSet
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MigrateTask

public MigrateTask()
Method Detail

setIgnoreFailedFutureMigration

public void setIgnoreFailedFutureMigration(boolean ignoreFailedFutureMigration)
Parameters:
ignoreFailedFutureMigration - Ignores failed future migrations when reading the metadata table. These are migrations that we 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 metadata table indicates that a migration to version 4.0 (unknown to us) has already been attempted and failed. Instead of bombing out (fail fast) with an exception, a warning is logged and Flyway terminates normally. This is useful for situations where a database rollback is not an option. An older version of the application can then be redeployed, even though a newer one failed due to a bad migration. (default: false)
Also configurable with Ant Property: ${flyway.ignoreFailedFutureMigration}

setValidationMode

@Deprecated
public void setValidationMode(String validationMode)
Deprecated. Use validateOnMigrate instead. Will be removed in Flyway 3.0.

Parameters:
validationMode - The type of validation to be performed before migrating.

Possible values are:

NONE (default)
No validation is performed.

ALL
For each sql migration a CRC32 checksum is calculated when the sql script is executed. The validate mechanism checks if the sql migrations in the classpath still has the same checksum as the sql migration already executed in the database.

Also configurable with Ant Property: ${flyway.validationMode}

setValidateOnMigrate

public void setValidateOnMigrate(boolean validateOnMigrate)
Parameters:
validateOnMigrate - Whether to automatically call validate or not when running migrate. (default: false)
Also configurable with Ant Property: ${flyway.validateOnMigrate}

setDisableInitCheck

@Deprecated
public void setDisableInitCheck(boolean disableInitCheck)
Deprecated. Use initOnMigrate instead. Will be removed in Flyway 3.0.

Parameters:
disableInitCheck - Flag to disable the check that a non-empty schema has been properly initialized with init. This check ensures Flyway does not migrate or clean the wrong database in case of a configuration mistake. Be careful when disabling this! (default: false)
Also configurable with Ant Property: ${flyway.disableInitCheck}

setInitOnMigrate

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!

Also configurable with Ant Property: ${flyway.initOnMigrate}

Parameters:
initOnMigrate - true if init should be called on migrate for non-empty schemas, false if not. (default: false)

doExecuteWithMigrationConfig

protected void doExecuteWithMigrationConfig(Flyway flyway)
                                     throws Exception
Description copied from class: AbstractMigrationLoadingTask
Executes Flyway fully configured for loading migrations.

Specified by:
doExecuteWithMigrationConfig in class AbstractMigrationLoadingTask
Parameters:
flyway - The instance of Flyway to launch.
Throws:
Exception - when the execution failed.


Copyright © 2012. All Rights Reserved.