Top Fields Constructors Methods
liquibase.command.core

public abstract Class AbstractUpdateCommandStep

extends AbstractCommandStep
implements CleanUpCommandStep
Class Inheritance
All Implemented Interfaces
liquibase.command.CleanUpCommandStep
Known Direct Subclasses
liquibase.command.core.UpdateCommandStep, liquibase.command.core.UpdateCountCommandStep, liquibase.command.core.UpdateSqlCommandStep, liquibase.command.core.UpdateToTagCommandStep
Imports
liquibase.*, liquibase.changelog.*, liquibase.changelog.filter.*, liquibase.changelog.visitor.*, liquibase.command.AbstractCommandStep, .CleanUpCommandStep, .CommandResultsBuilder, .CommandScope, liquibase.command.core.helpers.DatabaseChangelogCommandStep, liquibase.database.Database, liquibase.exception.DatabaseException, .LiquibaseException, .LockException, liquibase.executor.ExecutorService, liquibase.lockservice.LockService, .LockServiceFactory, liquibase.logging.mdc.MdcKey, .MdcObject, .MdcValue, liquibase.logging.mdc.customobjects.ChangesetsUpdated, liquibase.report.UpdateReportParameters, liquibase.util.ShowSummaryUtil, .StringUtil, .UpdateSummaryDetails, java.io.IOException, .OutputStream, java.util.*, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicInteger, java.util.stream.Collectors

Field Summary

Modifier and TypeField and Description
private static final String
public static final String
private boolean
private boolean
private final Map<String, Boolean>
upToDateFastCheck

Performs check of the historyService to determine if there is no unrun changesets without obtaining an exclusive write lock.

Inherited from liquibase.command.AbstractCommandStep:
coreBundle

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
addChangelogFileToMdc(String changeLogFile, DatabaseChangeLog databaseChangeLog)

public void
cleanUp(CommandResultsBuilder
builder used in this pipeline
resultsBuilder
)

Implements liquibase.command.CleanUpCommandStep.cleanUp.

Method invoked to execute the cleanup action.

protected void
private ChangeExecListener
public abstract String
public abstract String[]
public abstract String
private String

Returns:

the formatted command name
getFormattedCommandName
(String[]
the command name to reformat
commandName
)

Given a camel case command name array, format into a user-friendly command name string.

public abstract String
public abstract UpdateSummaryEnum
public UpdateSummaryOutputEnum
public ChangeLogIterator
getStandardChangelogIterator(CommandScope commandScope, Database database, Contexts contexts, LabelExpression labelExpression, DatabaseChangeLog changeLog)

protected List<ChangeSetFilter>
public ChangeLogIterator
getStatusChangelogIterator(CommandScope commandScope, Database database, Contexts contexts, LabelExpression labelExpression, DatabaseChangeLog changeLog)

private StatusVisitor
getStatusVisitor(CommandScope commandScope, Database database, Contexts contexts, LabelExpression labelExpression, DatabaseChangeLog databaseChangeLog)

public boolean

Returns:

true if there are no additional changes to execute, otherwise false
isUpToDate
(CommandScope commandScope, Database
the database to check
database
,
DatabaseChangeLog
the databaseChangeLog of the database
databaseChangeLog
,
Contexts
the command contexts
contexts
,
LabelExpression
the command label expressions
labelExpression
,
OutputStream
the current global OutputStream
outputStream
)

Checks if the database is up-to-date.

public boolean
isUpToDateFastCheck(CommandScope commandScope, Database database, DatabaseChangeLog databaseChangeLog, Contexts contexts, LabelExpression labelExpression)

private List<ChangeSet>

Returns:

a list of ChangeSet that have not been applied
listUnrunChangeSets
(Database
the target database
database
,
DatabaseChangeLog
the database changelog
databaseChangeLog
,
Contexts
the command contexts
contexts
,
LabelExpression
the command label expressions
labels
)

Get list of ChangeSet which have not been applied

private void
logDeploymentOutcomeMdc(ChangeExecListener defaultListener, boolean success, UpdateReportParameters updateReportParameters)

public void
postUpdateLog(int rowsAffected)

Log

protected void
preRun(CommandScope commandScope, ChangeLogIterator runChangeLogIterator, ChangeLogParameters changeLogParameters)

Executed before running any updates against the database.

public List<Class<?>>
requiredDependencies()

Overrides liquibase.command.AbstractCommandStep.requiredDependencies.

Implements liquibase.command.CommandStep.requiredDependencies.

Return a list of configured Classes that this command requires to be passed as a dependency.

public void
run(CommandResultsBuilder resultsBuilder)

Implements liquibase.command.CommandStep.run.

Performs the business logic.

protected void
setDBLock(boolean locked)

public void
setFastCheckEnabled(boolean fastCheckEnabled)

Inherited from liquibase.command.AbstractCommandStep:
adjustCommandDefinitiongetOrderprovidedDependenciesvalidate

Field Detail

DATABASE_UP_TO_DATE_MESSAGEback to summary
private static final String DATABASE_UP_TO_DATE_MESSAGE
DEFAULT_CHANGE_EXEC_LISTENER_RESULT_KEYback to summary
public static final String DEFAULT_CHANGE_EXEC_LISTENER_RESULT_KEY
isDBLockedback to summary
private boolean isDBLocked
isFastCheckEnabledback to summary
private boolean isFastCheckEnabled
upToDateFastCheckback to summary
private final Map<String, Boolean> upToDateFastCheck

Performs check of the historyService to determine if there is no unrun changesets without obtaining an exclusive write lock. This allows multiple peer services to boot in parallel in the common case where there are no changelogs to run.

If we see that there is nothing in the changelog to run and this returns true, then regardless of the lock status we already know we are "done" and can finish up without waiting for the lock.

But, if there are changelogs that might have to be ran and this returns false, you MUST get a lock and do a real check to know what changesets actually need to run.

Note

to reduce the number of queries to the databasehistory table, this method will cache the "fast check" results within this instance under the assumption that the total changesets will not change within this instance.

Constructor Detail

AbstractUpdateCommandStepback to summary
public AbstractUpdateCommandStep()

Method Detail

addChangelogFileToMdcback to summary
private void addChangelogFileToMdc(String changeLogFile, DatabaseChangeLog databaseChangeLog)
cleanUpback to summary
public void cleanUp(CommandResultsBuilder resultsBuilder)

Implements liquibase.command.CleanUpCommandStep.cleanUp.

Doc from liquibase.command.CleanUpCommandStep.cleanUp.

Method invoked to execute the cleanup action.

Parameters
resultsBuilder:CommandResultsBuilder

builder used in this pipeline

Annotations
@Override
customMdcLoggingback to summary
protected void customMdcLogging(CommandScope commandScope)
getChangeExecListenerback to summary
private ChangeExecListener getChangeExecListener(CommandResultsBuilder resultsBuilder, CommandScope commandScope)
getChangelogFileArgback to summary
public abstract String getChangelogFileArg(CommandScope commandScope)
getCommandNameback to summary
public abstract String[] getCommandName()
getContextsArgback to summary
public abstract String getContextsArg(CommandScope commandScope)
getFormattedCommandNameback to summary
private String getFormattedCommandName(String[] commandName)

Given a camel case command name array, format into a user-friendly command name string. Ex: Given {"updateToTag"}, produces "Update To Tag"

Parameters
commandName:String[]

the command name to reformat

Returns:String

the formatted command name

getLabelFilterArgback to summary
public abstract String getLabelFilterArg(CommandScope commandScope)
getShowSummaryback to summary
public abstract UpdateSummaryEnum getShowSummary(CommandScope commandScope)
getShowSummaryOutputback to summary
public UpdateSummaryOutputEnum getShowSummaryOutput(CommandScope commandScope)
getStandardChangelogIteratorback to summary
public ChangeLogIterator getStandardChangelogIterator(CommandScope commandScope, Database database, Contexts contexts, LabelExpression labelExpression, DatabaseChangeLog changeLog) throws LiquibaseException
Annotations
@Beta
getStandardChangelogIteratorFiltersback to summary
protected List<ChangeSetFilter> getStandardChangelogIteratorFilters(Database database, Contexts contexts, LabelExpression labelExpression)
getStatusChangelogIteratorback to summary
public ChangeLogIterator getStatusChangelogIterator(CommandScope commandScope, Database database, Contexts contexts, LabelExpression labelExpression, DatabaseChangeLog changeLog) throws LiquibaseException
Annotations
@Beta
getStatusVisitorback to summary
private StatusVisitor getStatusVisitor(CommandScope commandScope, Database database, Contexts contexts, LabelExpression labelExpression, DatabaseChangeLog databaseChangeLog) throws LiquibaseException
isUpToDateback to summary
public boolean isUpToDate(CommandScope commandScope, Database database, DatabaseChangeLog databaseChangeLog, Contexts contexts, LabelExpression labelExpression, OutputStream outputStream) throws LiquibaseException, IOException

Checks if the database is up-to-date.

Parameters
database:Database

the database to check

databaseChangeLog:DatabaseChangeLog

the databaseChangeLog of the database

contexts:Contexts

the command contexts

labelExpression:LabelExpression

the command label expressions

outputStream:OutputStream

the current global OutputStream

Returns:boolean

true if there are no additional changes to execute, otherwise false

Annotations
@Beta
Exceptions
LiquibaseException:
if there was a problem running any queries
IOException:
if there was a problem handling the update summary
isUpToDateFastCheckback to summary
public boolean isUpToDateFastCheck(CommandScope commandScope, Database database, DatabaseChangeLog databaseChangeLog, Contexts contexts, LabelExpression labelExpression) throws LiquibaseException
listUnrunChangeSetsback to summary
private List<ChangeSet> listUnrunChangeSets(Database database, DatabaseChangeLog databaseChangeLog, Contexts contexts, LabelExpression labels) throws LiquibaseException

Get list of ChangeSet which have not been applied

Parameters
database:Database

the target database

databaseChangeLog:DatabaseChangeLog

the database changelog

contexts:Contexts

the command contexts

labels:LabelExpression

the command label expressions

Returns:List<ChangeSet>

a list of ChangeSet that have not been applied

Exceptions
LiquibaseException:
if there was a problem building our ChangeLogIterator or checking the database
logDeploymentOutcomeMdcback to summary
private void logDeploymentOutcomeMdc(ChangeExecListener defaultListener, boolean success, UpdateReportParameters updateReportParameters)
postUpdateLogback to summary
public void postUpdateLog(int rowsAffected)

Log

Annotations
@Beta
preRunback to summary
protected void preRun(CommandScope commandScope, ChangeLogIterator runChangeLogIterator, ChangeLogParameters changeLogParameters) throws LiquibaseException

Executed before running any updates against the database.

requiredDependenciesback to summary
public List<Class<?>> requiredDependencies()

Overrides liquibase.command.AbstractCommandStep.requiredDependencies.

Implements liquibase.command.CommandStep.requiredDependencies.

Doc from liquibase.command.CommandStep.requiredDependencies.

Return a list of configured Classes that this command requires to be passed as a dependency.

Returns:List<Class<?>>

list with the required classes types

Annotations
@Override
runback to summary
public void run(CommandResultsBuilder resultsBuilder) throws Exception

Implements liquibase.command.CommandStep.run.

Doc from liquibase.command.CommandStep.run.

Performs the business logic. This method should not be called directly. It is called by the overall pipeline logic in the CommandScope#execute() order.

Annotations
@Override
setDBLockback to summary
protected void setDBLock(boolean locked)
setFastCheckEnabledback to summary
public void setFastCheckEnabled(boolean fastCheckEnabled)