Top Description Fields Constructors Methods
liquibase

public Class Liquibase

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Imports
liquibase.change.CheckSum, liquibase.changelog.*, liquibase.changelog.filter.*, liquibase.changelog.visitor.ChangeExecListener, .DefaultChangeExecListener, .ListVisitor, .StatusVisitor, liquibase.command.CommandResults, .CommandScope, liquibase.command.core.*, liquibase.command.core.helpers.*, liquibase.database.Database, .DatabaseConnection, .DatabaseFactory, liquibase.diff.DiffGeneratorFactory, .DiffResult, liquibase.diff.compare.CompareControl, liquibase.diff.output.changelog.DiffToChangeLog, liquibase.exception.CommandExecutionException, .DatabaseException, .LiquibaseException, liquibase.executor.Executor, .ExecutorService, .LoggingExecutor, liquibase.io.WriterOutputStream, liquibase.lockservice.DatabaseChangeLogLock, .LockServiceFactory, liquibase.logging.Logger, liquibase.logging.mdc.MdcKey, liquibase.parser.ChangeLogParser, .ChangeLogParserFactory, liquibase.parser.core.xml.XMLChangeLogSAXParser, liquibase.resource.ResourceAccessor, liquibase.serializer.ChangeLogSerializer, liquibase.structure.DatabaseObject, liquibase.util.LoggingExecutorTextUtil, .StringUtil, java.io.IOException, .PrintStream, .Writer, java.util.*, java.util.function.Supplier

Primary facade class for interacting with Liquibase. The built in command line, Ant, Maven and other ways of running Liquibase are wrappers around methods in this class.

Field Summary

Modifier and TypeField and Description
private ChangeExecListener
private String
private final ChangeLogParameters
private static final ResourceBundle
protected Database
private DatabaseChangeLog
private final DefaultChangeExecListener
private static final Logger
public static final String
private final ResourceAccessor
private UpdateSummaryEnum
private UpdateSummaryOutputEnum
private final Map<String, Boolean>

Constructor Summary

AccessConstructor and Description
public
Liquibase(String changeLogFile, ResourceAccessor resourceAccessor, DatabaseConnection conn)

Creates a Liquibase instance for a given DatabaseConnection.

public
Liquibase(String changeLogFile, ResourceAccessor resourceAccessor, Database database)

Creates a Liquibase instance.

public
Liquibase(DatabaseChangeLog changeLog, ResourceAccessor resourceAccessor, Database database)

Method Summary

Modifier and TypeMethod and Description
private void
addCommandFiltersMdc(LabelExpression labelExpression, Contexts contexts)

public final CheckSum
calculateCheckSum(final String changeSetIdentifier)
Deprecated Use \CommandScope(String).

Calculate the checksum for a given identifier

public CheckSum
calculateCheckSum(final String changeSetPath, final String changeSetId, final String changeSetAuthor)

Calculate the checksum for a given changeset specified by path, changeset id and author

public void
changeLogSync(String contexts, Writer output)

public void
changeLogSync(Contexts contexts, LabelExpression labelExpression, Writer output)

public void
public void
changeLogSync(Contexts contexts)
Deprecated use version with LabelExpression

public void
changeLogSync(Contexts contexts, LabelExpression labelExpression)

public void
changeLogSync(String tag, String contexts)

public void
changeLogSync(String
the tag up to which the changelog should be synchronized
tag
,
Contexts
the contexts to use for the synchronization
contexts
,
LabelExpression
the label expression to use for the synchronization
labelExpression
)

Synchronizes the changelog with the database up to a specified tag.

public void
changeLogSync(String tag, String contexts, Writer output)

public void
changeLogSync(String tag, Contexts contexts, LabelExpression labelExpression, Writer output)

public void
checkLiquibaseTables(boolean updateExistingNullChecksums, DatabaseChangeLog databaseChangeLog, Contexts contexts, LabelExpression labelExpression)

public void
clearCheckSums()
Deprecated Use CommandScope(String)

Sets checksums to null, so they will be repopulated next run

public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public DiffResult
diff(Database referenceDatabase, Database targetDatabase, CompareControl compareControl)
Deprecated Use \CommandScope(String) to generate diff instead of this method.

private void
doChangeLogSyncSql(String tag, Contexts contexts, LabelExpression labelExpression, Writer output, Supplier<String> header)

public final void
dropAll()

Drops all database objects in the default schema.

public final void
dropAll(CatalogAndSchema... schemas)

Drops all database objects in the passed schema(s).

private void
public void
public void
futureRollbackSQL(String contexts, Writer output)
Deprecated

public void
futureRollbackSQL(Writer output)
Deprecated

public void
futureRollbackSQL(String contexts, Writer output, boolean checkLiquibaseTables)
Deprecated

public void
futureRollbackSQL(Integer count, String contexts, Writer output)
Deprecated

public void
futureRollbackSQL(Contexts contexts, LabelExpression labelExpression, Writer output)
Deprecated

public void
futureRollbackSQL(Integer count, String contexts, Writer output, boolean checkLiquibaseTables)
Deprecated

public void
futureRollbackSQL(Integer count, Contexts contexts, LabelExpression labelExpression, Writer output)
Deprecated

public void
futureRollbackSQL(Integer count, Contexts contexts, LabelExpression labelExpression, Writer output, boolean checkLiquibaseTables)
Deprecated

public void
futureRollbackSQL(String tag, Contexts contexts, LabelExpression labelExpression, Writer output)
Deprecated

protected void
futureRollbackSQL(Integer count, String tag, Contexts contexts, LabelExpression labelExpression, Writer output)
Deprecated

protected void
futureRollbackSQL(Integer count, String tag, Contexts contexts, LabelExpression labelExpression, Writer output, boolean checkLiquibaseTables)
Deprecated

public final void
generateChangeLog(CatalogAndSchema catalogAndSchema, DiffToChangeLog changeLogWriter, PrintStream outputStream, Class<? extends DatabaseObject>... snapshotTypes)
Deprecated Use \CommandScope(String) to generateChangelog instead of this method.

public final void
generateChangeLog(CatalogAndSchema catalogAndSchema, DiffToChangeLog changeLogWriter, PrintStream outputStream, ChangeLogSerializer changeLogSerializer, Class<? extends DatabaseObject>... snapshotTypes)
Deprecated Use \CommandScope(String) to generateChangelog instead of this method.

public void
generateDocumentation(String outputDirectory)
Deprecated

public void
generateDocumentation(String outputDirectory, String contexts)
Deprecated

public void
generateDocumentation(String outputDirectory, String contexts, CatalogAndSchema... schemaList)
Deprecated

public void
generateDocumentation(String outputDirectory, Contexts contexts, LabelExpression labelExpression, CatalogAndSchema... schemaList)
Deprecated Use CommandScope to generate dbDoc instead of this method.

private Executor
public String
getChangeLogFile()

Return the change log file used by this Liquibase instance.

public ChangeLogParameters
getChangeLogParameters()

Returns the ChangeLogParameters container used by this Liquibase instance.

public List<ChangeSetStatus>
getChangeSetStatuses(Contexts contexts)
Deprecated use version with LabelExpression

public List<ChangeSetStatus>
getChangeSetStatuses(Contexts contexts, LabelExpression labelExpression)

public List<ChangeSetStatus>
getChangeSetStatuses(Contexts contexts, LabelExpression labelExpression, boolean checkLiquibaseTables)

Returns the ChangeSetStatuses of all changesets in the change log file and history in the order they would be ran.

public Database
getDatabase()

Returns the Database used by this Liquibase instance.

public DatabaseChangeLog
private DatabaseChangeLog
getDatabaseChangeLog(boolean
When set to true, a warning will be printed to the console if the XSD version used does not match the version of Liquibase. If "latest" is used as the XSD version, no warning is printed. If the changelog is not xml format, no warning is printed.
shouldWarnOnMismatchedXsdVersion
)

public DefaultChangeExecListener
public Logger
getLog()

Return the log used by this Liquibase instance.

public ResourceAccessor
getResourceAccessor()

Return ResourceAccessor used by this Liquibase instance.

protected ChangeLogIterator

Returns:

a ChangeLogIterator instance.
getStandardChangelogIterator
(Contexts
The contexts to filter for.
contexts
,
LabelExpression
The labels to filter for.
labelExpression
,
DatabaseChangeLog
The changelog to process.
changeLog
)

Return a ChangeLogIterator constructed with standard filters for processing the specified changelog.

public boolean
isSafeToRunUpdate()

Returns true if it is "save" to migrate the database.

protected boolean
isUpToDateFastCheck(Contexts contexts, LabelExpression labelExpression)
Deprecated this method has been moved to AbstractUpdateCommandStep, use that one instead.

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

public DatabaseChangeLogLock[]
listLocks()
Deprecated

Display change log lock information.

public Collection<RanChangeSet>
listUnexpectedChangeSets(String contexts)
Deprecated

public Collection<RanChangeSet>
listUnexpectedChangeSets(Contexts contexts, LabelExpression labelExpression)
Deprecated

public List<ChangeSet>
listUnrunChangeSets(Contexts contexts)
Deprecated use version with LabelExpression

public List<ChangeSet>
listUnrunChangeSets(Contexts contexts, LabelExpression labels)
Deprecated

public List<ChangeSet>
listUnrunChangeSets(Contexts contexts, LabelExpression labels, boolean checkLiquibaseTables)
Deprecated

public void
markNextChangeSetRan(String contexts, Writer output)
Deprecated

public void
markNextChangeSetRan(Contexts contexts, LabelExpression labelExpression, Writer output)
Deprecated

public void
markNextChangeSetRan(String contexts)
Deprecated

public void
markNextChangeSetRan(Contexts contexts, LabelExpression labelExpression)
Deprecated

public void
public void
reportLocks(PrintStream out)
Deprecated

public void
reportStatus(boolean verbose, String contexts, Writer out)
Deprecated

public void
reportStatus(boolean verbose, Contexts contexts, Writer out)
Deprecated

public void
reportStatus(boolean verbose, Contexts contexts, LabelExpression labels, Writer out)
Deprecated

public void
reportUnexpectedChangeSets(boolean verbose, String contexts, Writer out)
Deprecated

public void
reportUnexpectedChangeSets(boolean verbose, Contexts contexts, LabelExpression labelExpression, Writer out)
Deprecated

protected void
public void
rollback(int changesToRollback, String contexts, Writer output)

public void
rollback(int changesToRollback, Contexts contexts, Writer output)

public void
rollback(int changesToRollback, Contexts contexts, LabelExpression labelExpression, Writer output)

public void
rollback(int changesToRollback, String rollbackScript, String contexts, Writer output)

public void
rollback(int changesToRollback, String rollbackScript, Contexts contexts, Writer output)

public void
rollback(int changesToRollback, String rollbackScript, Contexts contexts, LabelExpression labelExpression, Writer output)

public void
rollback(int changesToRollback, String contexts)

public void
rollback(int changesToRollback, Contexts contexts, LabelExpression labelExpression)

public void
rollback(int changesToRollback, String rollbackScript, String contexts)

public void
rollback(int
the number of changesets to roll back
changesToRollback
,
String
the path to a custom SQL script to use for the rollback, or `null` to use Liquibase's built-in rollback functionality
rollbackScript
,
Contexts
the contexts to include in the rollback, or `null` to include all contexts
contexts
,
LabelExpression
the labels to include in the rollback, or `null` to include all labels
labelExpression
)

Rolls back a specified number of changesets.

public void
rollback(String tagToRollBackTo, String contexts, Writer output)
Deprecated

public void
rollback(String tagToRollBackTo, Contexts contexts, Writer output)
Deprecated

public void
rollback(String tagToRollBackTo, Contexts contexts, LabelExpression labelExpression, Writer output)
Deprecated

public void
rollback(String tagToRollBackTo, String rollbackScript, String contexts, Writer output)
Deprecated

public void
rollback(String tagToRollBackTo, String rollbackScript, Contexts contexts, Writer output)
Deprecated

public void
rollback(String tagToRollBackTo, String rollbackScript, Contexts contexts, LabelExpression labelExpression, Writer output)
Deprecated

public void
rollback(String tagToRollBackTo, String contexts)
Deprecated

public void
rollback(String tagToRollBackTo, Contexts contexts)
Deprecated

public void
rollback(String tagToRollBackTo, Contexts contexts, LabelExpression labelExpression)
Deprecated

public void
rollback(String tagToRollBackTo, String rollbackScript, String contexts)
Deprecated

public void
rollback(String tagToRollBackTo, String rollbackScript, Contexts contexts)
Deprecated

public void
rollback(String
the tag to which the database should be rolled back.
tagToRollBackTo
,
String
an optional path to a user-defined rollback script. If null, Liquibase will generate the rollback SQL automatically.
rollbackScript
,
Contexts
a list of contexts to include when rolling back the database. May be null.
contexts
,
LabelExpression
a label expression to filter the change sets to rollback. May be null.
labelExpression
)

Rolls back the database to a specific tag, using either a generated or user-defined rollback script.

public void
rollback(Date dateToRollBackTo, String contexts, Writer output)

public void
rollback(Date dateToRollBackTo, String rollbackScript, String contexts, Writer output)

public void
rollback(Date dateToRollBackTo, Contexts contexts, LabelExpression labelExpression, Writer output)

public void
rollback(Date dateToRollBackTo, String rollbackScript, Contexts contexts, LabelExpression labelExpression, Writer output)

public void
rollback(Date dateToRollBackTo, String contexts)

public void
rollback(Date dateToRollBackTo, Contexts contexts, LabelExpression labelExpression)

public void
rollback(Date dateToRollBackTo, String rollbackScript, String contexts)

public void
rollback(Date
the date to roll back to
dateToRollBackTo
,
String
the path to a SQL script to execute for the rollback (optional)
rollbackScript
,
Contexts
the contexts to execute the rollback in (optional)
contexts
,
LabelExpression
the label expression to use for filtering change sets (optional)
labelExpression
)

Rolls back all changesets that were applied after the specified date.

private void
runInScope(Scope.ScopedRunner<T> scopedRunner)

public void
public void
public void
public void
public void
tag(String tagString)
Deprecated Use CommandScope(String) to tag instead of this method.

'Tags' the database for future rollback

public boolean
tagExists(String tagString)
Deprecated Use \CommandScope(String) to verify tag exist instead of this method.

Verifies if a given tag exist in the database

public void
update()
Deprecated use CommandScope

public void
update(String contexts)
Deprecated use CommandScope

public void
update(Contexts contexts)
Deprecated use CommandScope

public void
update(Contexts contexts, LabelExpression labelExpression)
Deprecated use CommandScope

public void
update(Contexts contexts, LabelExpression labelExpression, boolean checkLiquibaseTables)
Deprecated use CommandScope

public void
update(String contexts, Writer output)
Deprecated

public void
update(Contexts contexts, Writer output)
Deprecated

public void
update(Contexts contexts, LabelExpression labelExpression, Writer output)
Deprecated

public void
update(Contexts contexts, LabelExpression labelExpression, Writer output, boolean checkLiquibaseTables)
Deprecated

public void
update(int changesToApply, String contexts)
Deprecated

public void
update(int
the number of changesets to apply.
changesToApply
,
Contexts
the contexts in which the changesets should be applied.
contexts
,
LabelExpression
the label expression used to filter the changesets.
labelExpression
)
Deprecated

Updates the database schema with the specified number of changesets, within the given contexts and matching the given label expression.

public void
update(String tag, String contexts)
Deprecated

public void
update(String tag, Contexts contexts)
Deprecated

public void
update(String
The tag to update the database to.
tag
,
Contexts
The contexts to execute in.
contexts
,
LabelExpression
The label expression to execute with.
labelExpression
)
Deprecated

Updates the database to a specified tag.

public void
update(int changesToApply, String contexts, Writer output)
Deprecated

public void
update(int changesToApply, Contexts contexts, LabelExpression labelExpression, Writer output)
Deprecated

public void
update(String tag, String contexts, Writer output)
Deprecated

public void
update(String tag, Contexts contexts, Writer output)
Deprecated

public void
update(String tag, Contexts contexts, LabelExpression labelExpression, Writer output)
Deprecated

public void
updateTestingRollback(String contexts)
Deprecated

public void
updateTestingRollback(Contexts contexts, LabelExpression labelExpression)
Deprecated

public void
updateTestingRollback(String tag, Contexts contexts, LabelExpression labelExpression)
Deprecated

public void
validate()
Deprecated use CommandScope

Checks changelogs for bad MD5Sums and preconditions before attempting a migration

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait