org.dbmaintain.launch.ant
Class UpdateDatabaseAntTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.dbmaintain.launch.ant.BaseAntTask
              extended by org.dbmaintain.launch.ant.BaseDatabaseAntTask
                  extended by org.dbmaintain.launch.ant.UpdateDatabaseAntTask

public class UpdateDatabaseAntTask
extends BaseDatabaseAntTask

Task that updates the database to the latest version.

Author:
Filip Neven, Tim Ducheyne

Field Summary
 
Fields inherited from class org.dbmaintain.launch.ant.BaseDatabaseAntTask
databases
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
UpdateDatabaseAntTask()
           
 
Method Summary
protected  DbMaintainTask createDbMaintainTask()
           
 void setAllowOutOfSequenceExecutionOfPatches(boolean allowOutOfSequenceExecutionOfPatches)
          If this property is set to true, a patch script is allowed to be executed even if another script with a higher index was already executed.
 void setAutoCreateDbMaintainScriptsTable(boolean autoCreateDbMaintainScriptsTable)
          If set to true, the table DBMAINTAIN_SCRIPTS will be created automatically if it does not exist yet.
 void setCleanDb(boolean cleanDb)
          Indicates whether the database should be 'cleaned' before scripts are executed.
 void setDisableConstraints(boolean disableConstraints)
          If set to true, all foreign key and not null constraints of the database are automatically disabled before and after the execution of the scripts.
 void setExcludedQualifiers(String excludedQualifiers)
          Optional comma-separated list of script qualifiers.
 void setFromScratchEnabled(boolean fromScratchEnabled)
          Sets the fromScratchEnabled property, that indicates the database can be recreated from scratch if needed.
 void setIncludedQualifiers(String includedQualifiers)
          Optional comma-separated list of script qualifiers.
 void setPatchQualifiers(String patchQualifiers)
          The qualifiers to use to determine whether a script is a patch script.
 void setPostProcessingScriptDirectoryName(String postProcessingScriptDirectoryName)
          Comma separated list of directories and files in which the post processing database scripts are located.
 void setQualifiers(String qualifiers)
          Optional comma-separated list of script qualifiers.
 void setScriptEncoding(String scriptEncoding)
          Encoding to use when reading the script files.
 void setScriptFileExtensions(String scriptFileExtensions)
          Sets the scriptFileExtensions property, that defines the extensions of the files that are regarded to be database scripts.
 void setScriptLocations(String scriptLocations)
          Defines where the scripts can be found that must be executed on the database.
 void setScriptParameterFile(String scriptParameterFile)
          If set, the given properties file will be loaded and all occurrences of parameters in the script that match a property will be replaced by the corresponding property value.
 void setUpdateSequences(boolean updateSequences)
          If set to true, all sequences and identity columns are set to a sufficiently high value, so that test data can be inserted without having manually chosen test record IDs clashing with automatically generated keys.
 void setUseLastModificationDates(boolean useLastModificationDates)
          Defines whether the last modification dates of the scripts files can be used to determine whether the contents of a script has changed.
 
Methods inherited from class org.dbmaintain.launch.ant.BaseDatabaseAntTask
addDatabase, getDbMaintainDatabases
 
Methods inherited from class org.dbmaintain.launch.ant.BaseAntTask
execute, getAntProperties, getCustomConfigFile, setConfigFile
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UpdateDatabaseAntTask

public UpdateDatabaseAntTask()
Method Detail

createDbMaintainTask

protected DbMaintainTask createDbMaintainTask()
Specified by:
createDbMaintainTask in class BaseAntTask

setScriptLocations

public void setScriptLocations(String scriptLocations)
Defines where the scripts can be found that must be executed on the database. Multiple locations may be configured, separated by comma's. A script location can be a folder or a jar file. This property is required.

Parameters:
scriptLocations - Comma separated list of script locations

setScriptEncoding

public void setScriptEncoding(String scriptEncoding)
Encoding to use when reading the script files. Defaults to ISO-8859-1

Parameters:
scriptEncoding - The encoding

setPostProcessingScriptDirectoryName

public void setPostProcessingScriptDirectoryName(String postProcessingScriptDirectoryName)
Comma separated list of directories and files in which the post processing database scripts are located. Directories in this list are recursively search for files. Defaults to postprocessing

Parameters:
postProcessingScriptDirectoryName - The directory names

setFromScratchEnabled

public void setFromScratchEnabled(boolean fromScratchEnabled)
Sets the fromScratchEnabled property, that indicates the database can be recreated from scratch if needed. From-scratch recreation is needed in following cases: If set to false, the DbMaintainer will give an error if one of these situations occurs. The default is false.

Parameters:
fromScratchEnabled - True if the database can be updated from scratch.

setAutoCreateDbMaintainScriptsTable

public void setAutoCreateDbMaintainScriptsTable(boolean autoCreateDbMaintainScriptsTable)
If set to true, the table DBMAINTAIN_SCRIPTS will be created automatically if it does not exist yet. If false, an exception is thrown, indicating how to create the table manually. False by default.

Parameters:
autoCreateDbMaintainScriptsTable - True if the DBMAINTAIN_SCRIPTS table can be created automatically

setQualifiers

public void setQualifiers(String qualifiers)
Optional comma-separated list of script qualifiers. All custom qualifiers that are used in script file names must be declared.

Parameters:
qualifiers - the registered (allowed) script qualifiers

setPatchQualifiers

public void setPatchQualifiers(String patchQualifiers)
The qualifiers to use to determine whether a script is a patch script. Defaults to patch. E.g. 01_#patch_myscript.sql

Parameters:
patchQualifiers - The patch qualifiers

setIncludedQualifiers

public void setIncludedQualifiers(String includedQualifiers)
Optional comma-separated list of script qualifiers. All included qualifiers must be registered using the qualifiers property. Only scripts which are qualified with one of the included qualifiers will be executed.

Parameters:
includedQualifiers - the included script qualifiers

setExcludedQualifiers

public void setExcludedQualifiers(String excludedQualifiers)
Optional comma-separated list of script qualifiers. All excluded qualifiers must be registered using the qualifiers property. Scripts qualified with one of the excluded qualifiers will not be executed.

Parameters:
excludedQualifiers - the excluded script qualifiers

setAllowOutOfSequenceExecutionOfPatches

public void setAllowOutOfSequenceExecutionOfPatches(boolean allowOutOfSequenceExecutionOfPatches)
If this property is set to true, a patch script is allowed to be executed even if another script with a higher index was already executed.

Parameters:
allowOutOfSequenceExecutionOfPatches - true if out-of-sequence execution of patches is enabled

setCleanDb

public void setCleanDb(boolean cleanDb)
Indicates whether the database should be 'cleaned' before scripts are executed. If true, the records of all database tables, except for the ones listed in 'dbMaintainer.preserve.*' or 'dbMaintain.preserveDataOnly.*' are deleted before and after executing the scripts. False by default.

Parameters:
cleanDb - True if the database must be 'cleaned' before executing scripts.

setDisableConstraints

public void setDisableConstraints(boolean disableConstraints)
If set to true, all foreign key and not null constraints of the database are automatically disabled before and after the execution of the scripts. False by default.

Parameters:
disableConstraints - True if constraints must be disabled.

setUpdateSequences

public void setUpdateSequences(boolean updateSequences)
If set to true, all sequences and identity columns are set to a sufficiently high value, so that test data can be inserted without having manually chosen test record IDs clashing with automatically generated keys.

Parameters:
updateSequences - True if sequences and identity columns have to be updated.

setScriptFileExtensions

public void setScriptFileExtensions(String scriptFileExtensions)
Sets the scriptFileExtensions property, that defines the extensions of the files that are regarded to be database scripts. The extensions should not start with a dot. The default is 'sql,ddl'.

Parameters:
scriptFileExtensions - Comma separated list of file extensions.

setUseLastModificationDates

public void setUseLastModificationDates(boolean useLastModificationDates)
Defines whether the last modification dates of the scripts files can be used to determine whether the contents of a script has changed. If set to true, DbMaintain will not look at the contents of scripts that were already executed on the database, if the last modification date is still the same. If it did change, it will first calculate the checksum of the file to verify that the content really changed. Setting this property to true improves performance: if set to false the checksum of every script must be calculated for each run. True by default.

Parameters:
useLastModificationDates - True if script file last modification dates can be used.

setScriptParameterFile

public void setScriptParameterFile(String scriptParameterFile)
If set, the given properties file will be loaded and all occurrences of parameters in the script that match a property will be replaced by the corresponding property value. Script parameters are formatted as in ${param}.

Parameters:
scriptParameterFile - path of the properties file to be loaded


Copyright © 2011. All Rights Reserved.