|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dbmaintain.DefaultDbMaintainer
public class DefaultDbMaintainer
Class that offers operations for automatically maintaining a database.
TheupdateDatabase(boolean)
operation can be used to bring the database to the latest version. The
markDatabaseAsUpToDate()
operation updates the state of the database to indicate that all scripts have been
executed, without actually executing them.
Field Summary | |
---|---|
protected boolean |
allowOutOfSequenceExecutionOfPatchScripts
|
protected ScriptIndexes |
baseLineRevision
|
protected boolean |
cleanDb
|
protected ConstraintsDisabler |
constraintsDisabler
|
protected DBCleaner |
dbCleaner
|
protected DBClearer |
dbClearer
|
protected boolean |
disableConstraints
|
protected ExecutedScriptInfoSource |
executedScriptInfoSource
|
protected boolean |
fromScratchEnabled
Indicates whether updating the database from scratch is enabled. |
protected long |
maxNrOfCharsWhenLoggingScriptContent
|
protected ScriptRepository |
scriptRepository
|
protected ScriptRunner |
scriptRunner
|
protected ScriptUpdatesFormatter |
scriptUpdatesFormatter
|
protected SequenceUpdater |
sequenceUpdater
|
protected SQLHandler |
sqlHandler
|
protected boolean |
updateSequences
|
protected boolean |
useScriptFileLastModificationDates
Defines whether script last modification dates can be used to decide whether an existing script has changed. |
Constructor Summary | |
---|---|
DefaultDbMaintainer(ScriptRunner scriptRunner,
ScriptRepository scriptRepository,
ExecutedScriptInfoSource executedScriptInfoSource,
boolean fromScratchEnabled,
boolean useScriptFileLastModificationDates,
boolean allowOutOfSequenceExecutionOfPatchScripts,
boolean cleanDb,
boolean disableConstraints,
boolean updateSequences,
DBClearer dbClearer,
DBCleaner dbCleaner,
ConstraintsDisabler constraintsDisabler,
SequenceUpdater sequenceUpdater,
ScriptUpdatesFormatter scriptUpdatesFormatter,
SQLHandler sqlHandler,
long maxNrOfCharsWhenLoggingScriptContent,
ScriptIndexes baseLineRevision)
Creates a new instance |
Method Summary | |
---|---|
protected void |
executePostprocessingScripts()
Executes all postprocessing scripts |
protected void |
executeScript(Script script)
Executes the given script and updates the database execution registry appropriately. |
protected void |
executeScripts(SortedSet<Script> scripts)
Executes the given scripts and updates the database execution registry appropriately. |
protected void |
executeScriptUpdates(SortedSet<ScriptUpdate> scriptUpdates)
Executes the given scripts and updates the database execution registry appropriately. |
protected Map<Script,ExecutedScript> |
getAlreadyExecutedScripts()
|
protected String |
getErrorMessage(Script script,
DbMaintainException e)
|
protected String |
getErrorScriptOptionsMessage(Script script)
|
protected SortedSet<ExecutedScript> |
getIncrementalScriptsThatFailedDuringLastUpdate()
|
protected SortedSet<ExecutedScript> |
getRepeatableScriptsThatFailedDuringLastUpdate()
|
ScriptUpdates |
getScriptUpdates()
This operation calcutes and logs which script updates have been performed since the last database update. |
protected boolean |
isInitialDatabaseUpdate()
|
void |
markDatabaseAsUpToDate()
This operation updates the state of the database to indicate that all scripts have been executed, without actually executing them. |
protected void |
performRegularScriptRenamesInExecutedScripts(SortedSet<ScriptUpdate> regularScriptRenames)
Updates the records in the DBMAINTAIN_SCRIPTS table for all scripts that were regularly renamed (i.e. renamed without changing the order of the incremental scripts. |
protected void |
removeDeletedRepeatableScriptsFromExecutedScripts(SortedSet<ScriptUpdate> repeatableScriptDeletions)
Removes all executed scripts that indicate repeatable scripts that were removed since the last database update |
boolean |
updateDatabase(boolean dryRun)
This operation can be used to bring the database to the latest version. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ExecutedScriptInfoSource executedScriptInfoSource
protected ScriptRepository scriptRepository
protected ScriptRunner scriptRunner
protected DBClearer dbClearer
protected DBCleaner dbCleaner
protected ConstraintsDisabler constraintsDisabler
protected SequenceUpdater sequenceUpdater
protected SQLHandler sqlHandler
protected boolean cleanDb
protected boolean fromScratchEnabled
protected boolean useScriptFileLastModificationDates
protected boolean allowOutOfSequenceExecutionOfPatchScripts
protected boolean disableConstraints
protected boolean updateSequences
protected ScriptUpdatesFormatter scriptUpdatesFormatter
protected long maxNrOfCharsWhenLoggingScriptContent
protected ScriptIndexes baseLineRevision
Constructor Detail |
---|
public DefaultDbMaintainer(ScriptRunner scriptRunner, ScriptRepository scriptRepository, ExecutedScriptInfoSource executedScriptInfoSource, boolean fromScratchEnabled, boolean useScriptFileLastModificationDates, boolean allowOutOfSequenceExecutionOfPatchScripts, boolean cleanDb, boolean disableConstraints, boolean updateSequences, DBClearer dbClearer, DBCleaner dbCleaner, ConstraintsDisabler constraintsDisabler, SequenceUpdater sequenceUpdater, ScriptUpdatesFormatter scriptUpdatesFormatter, SQLHandler sqlHandler, long maxNrOfCharsWhenLoggingScriptContent, ScriptIndexes baseLineRevision)
scriptRunner
- runner that executes the database scriptsscriptRepository
- provides access to all database scriptsexecutedScriptInfoSource
- provides information about which scripts were already executed on the databasefromScratchEnabled
- if true, the database will be cleared and recreated from scratch if neededuseScriptFileLastModificationDates
- if true, the dbmaintainer decides that a script hasn't changed if the
last modification date is identical to the one of the last update, without looking at the contents of the scriptallowOutOfSequenceExecutionOfPatchScripts
- if true, patch scripts can be executed out-of-sequencecleanDb
- if true, the data from all tables is removed before performing any updatesdisableConstraints
- if true, all foreign key and not null constraints are automatically disabled
or removed after each updateupdateSequences
- if true, the value of all sequences is set to a minimal value after each updatedbClearer
- helper object that clears the database, i.e. drop all database objectsdbCleaner
- helper object that cleans the database, i.e. remove the data from all tablesconstraintsDisabler
- helper object that disables or removes all foreign key or not null constraintssequenceUpdater
- helper object that updates all sequences to a minimal valuescriptUpdatesFormatter
- helper object that formats the script updates in a well-readable format for the usersqlHandler
- helper object that performs sql statements on the databasemaxNrOfCharsWhenLoggingScriptContent
- The maximum length of a script that is logged in an exception, 0 to not log any script contentbaseLineRevision
- The baseline revision. If set, all scripts with a lower revision will be ignoredMethod Detail |
---|
public boolean updateDatabase(boolean dryRun)
updateDatabase
in interface DbMaintainer
dryRun
- if true, no updates have to be performed on the database - we do a simulation of the database update
instead of actually performing the database update.
public ScriptUpdates getScriptUpdates()
protected boolean isInitialDatabaseUpdate()
protected void executePostprocessingScripts()
protected Map<Script,ExecutedScript> getAlreadyExecutedScripts()
protected void removeDeletedRepeatableScriptsFromExecutedScripts(SortedSet<ScriptUpdate> repeatableScriptDeletions)
repeatableScriptDeletions
- The scripts that were removed since the last database updatesprotected void performRegularScriptRenamesInExecutedScripts(SortedSet<ScriptUpdate> regularScriptRenames)
regularScriptRenames
- the scripts that were regularly renamedpublic void markDatabaseAsUpToDate()
markDatabaseAsUpToDate
in interface DbMaintainer
protected void executeScriptUpdates(SortedSet<ScriptUpdate> scriptUpdates)
scriptUpdates
- the script updates to be executedprotected void executeScripts(SortedSet<Script> scripts)
scripts
- the scripts to be executed on the databaseprotected void executeScript(Script script)
script
- The script to execute, not nullprotected String getErrorMessage(Script script, DbMaintainException e)
protected String getErrorScriptOptionsMessage(Script script)
protected SortedSet<ExecutedScript> getIncrementalScriptsThatFailedDuringLastUpdate()
protected SortedSet<ExecutedScript> getRepeatableScriptsThatFailedDuringLastUpdate()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |