Top Description Fields Constructors Methods
liquibase.change

public abstract Class AbstractChange

extends AbstractPlugin
implements Change
Class Inheritance
All Implemented Interfaces
liquibase.change.Change, liquibase.ExtensibleObject, java.lang.Cloneable, liquibase.plugin.Plugin, liquibase.serializer.LiquibaseSerializable
Known Direct Subclasses
liquibase.change.AbstractSQLChange, liquibase.change.AbstractTableChange, liquibase.change.core.DropPrimaryKeyChange, liquibase.change.core.AbstractModifyDataChange, liquibase.change.core.AddAutoIncrementChange, liquibase.change.core.AddColumnChange, liquibase.change.core.AddDefaultValueChange, liquibase.change.core.AddForeignKeyConstraintChange, liquibase.change.core.AddLookupTableChange, liquibase.change.core.AddNotNullConstraintChange, liquibase.change.core.AddPrimaryKeyChange, liquibase.change.core.AddUniqueConstraintChange, liquibase.change.core.AlterSequenceChange, liquibase.change.core.CreateIndexChange, liquibase.change.core.CreateProcedureChange, liquibase.change.core.CreateSequenceChange, liquibase.change.core.CreateTableChange, liquibase.change.core.CreateViewChange, liquibase.change.core.DropAllForeignKeyConstraintsChange, liquibase.change.core.DropColumnChange, liquibase.change.core.DropDefaultValueChange, liquibase.change.core.DropForeignKeyConstraintChange, liquibase.change.core.DropIndexChange, liquibase.change.core.DropNotNullConstraintChange, liquibase.change.core.DropProcedureChange, liquibase.change.core.DropSequenceChange, liquibase.change.core.DropTableChange, liquibase.change.core.DropUniqueConstraintChange, liquibase.change.core.DropViewChange, liquibase.change.core.EmptyChange, liquibase.change.core.ExecuteShellCommandChange, liquibase.change.core.InsertDataChange, liquibase.change.core.MergeColumnChange, liquibase.change.core.ModifyDataTypeChange, liquibase.change.core.OutputChange, liquibase.change.core.RenameColumnChange, liquibase.change.core.RenameSequenceChange, liquibase.change.core.RenameTableChange, liquibase.change.core.RenameViewChange, liquibase.change.core.SetColumnRemarksChange, liquibase.change.core.SetTableRemarksChange, liquibase.change.core.StopChange, liquibase.change.core.TagDatabaseChange, liquibase.change.custom.CustomChangeWrapper
Imports
liquibase.ChecksumVersion, .Scope, liquibase.change.visitor.ChangeVisitor, liquibase.changelog.ChangeSet, liquibase.database.Database, liquibase.exception.*, liquibase.executor.Executor, .ExecutorService, .LoggingExecutor, liquibase.parser.core.ParsedNode, .ParsedNodeException, liquibase.plugin.AbstractPlugin, liquibase.resource.ResourceAccessor, liquibase.serializer.LiquibaseSerializable, liquibase.serializer.core.string.StringChangeLogSerializer, liquibase.sqlgenerator.SqlGeneratorFactory, liquibase.statement.SqlStatement, liquibase.structure.DatabaseObject, liquibase.util.BooleanUtil, .ObjectUtil, .StringUtil, java.beans.IntrospectionException, .PropertyDescriptor, java.lang.reflect.Method, .Modifier, .Type, java.util.*

Standard superclass to simplify Change implementations. You can implement Change directly, this class is purely for convenience but recommended. By default, this base class relies on annotations such as DatabaseChange and DatabaseChangeProperty and delegating logic to the liquibase.sqlgenerator.SqlGenerator objects created to do the actual change work. Place the @DatabaseChangeProperty annotations on the read "get" methods to control property metadata.

Field Summary

Modifier and TypeField and Description
private ChangeSet
protected static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ChangeStatus
checkStatus(Database database)

Implements liquibase.change.Change.checkStatus.

Validate that this change executed successfully against the given database.

public ChangeMetaData
createChangeMetaData()

Implements liquibase.change.Change.createChangeMetaData.

Generate the ChangeMetaData for this class.

protected ChangeParameterMetaData
createChangeParameterMetadata(String parameterName)

Called by createChangeMetaData() to create metadata for a given parameter.

private ChangeParameterMetaData
protected String
createDescriptionMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "description" value.

protected ColumnConfig
createEmptyColumnConfig(Class<T> collectionType)

protected Map<String, Object>
createExampleValueMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "example" value.

protected Change[]

Returns:

Return null if there is no corresponding inverse and therefore automatic rollback is not possible. Return an empty array to have a no-op rollback.
createInverses
()

Create inverse changes that can roll back this change.

protected String
createMustEqualExistingMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "mustEqual" value.

protected String[]
createRequiredDatabasesMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "requiredDatabases" value.

protected LiquibaseSerializable.SerializationType
createSerializationTypeMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "serializationType" value.

protected String
createSinceMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "since" value.

protected String[]
createSupportedDatabasesMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "supportedDatabase" value.

protected void
customLoadLogic(ParsedNode parsedNode, ResourceAccessor resourceAccessor)

public boolean
equals(Object
the reference object with which to compare.
reference
)

Overrides liquibase.AbstractExtensibleObject.equals.

Default implementation counts objects equal if their describe() methods return equal strings.

private DatabaseChangeProperty
findDatabaseChangePropertyAnnotationMatchingCurrentChecksumVersion(Method readMethod)

Given a particular method, find the DatabaseChangeProperty annotation on it that most precisely matches the requested checksum version.

public void
finishInitialization()

Implements liquibase.change.Change.finishInitialization.

Default implementation is a no-op

public CheckSum
generateCheckSum()

Implements liquibase.change.Change.generateCheckSum.

Implementation generates checksum by serializing the change with StringChangeLogSerializer

public SqlStatement[]
generateRollbackStatements(Database database)

Implements liquibase.change.Change.generateRollbackStatements.

Implementation relies on value returned from createInverses().

private SqlStatement[]
public boolean
generateRollbackStatementsVolatile(Database database)

Implements liquibase.change.Change.generateRollbackStatementsVolatile.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#generateRollbackStatementsIsVolatile(Database) method on the SqlStatement objects returned by generateStatements If no or null SqlStatements are returned by generateRollbackStatements then this method returns false.

public boolean
public Set<DatabaseObject>
getAffectedDatabaseObjects(Database database)

Implements liquibase.change.Change.getAffectedDatabaseObjects.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGeneratorFactory#getAffectedDatabaseObjects(liquibase.statement.SqlStatement, liquibase.database.Database) method on the SqlStatement objects returned by generateStatements Returns empty set if change is not supported for the passed database

public ChangeSet
getChangeSet()

Implements liquibase.change.Change.getChangeSet.

Returns the changeSet this Change is part of.

public String
getDescription()

Implements liquibase.change.Change.getDescription.

Short, scannable description for the DATABASECHANGELOG.DESCRIPTION column

public String[]
public ResourceAccessor
getResourceAccessor()
Deprecated Should get from Scope

public String
public Set<String>
getSerializableFields()

Implements liquibase.serializer.LiquibaseSerializable.getSerializableFields.

Returns the fields on this change that are serializable.

public LiquibaseSerializable.SerializationType
public Object
public String
public String
public int
hashCode()

Overrides liquibase.AbstractExtensibleObject.hashCode.

Returns a hash code value for this object.

protected boolean
public void
public void
public ParsedNode
protected Object
public void
setChangeSet(ChangeSet changeSet)

Implements liquibase.change.Change.setChangeSet.

Sets the changeSet this Change is a part of.

public void
setResourceAccessor(ResourceAccessor resourceAccessor)

Implements liquibase.change.Change.setResourceAccessor.

Sets the ResourceAccessor that should be used for any file and/or resource loading needed by this Change.

public boolean

Returns:

boolean
shouldExecuteChange
(Database
Database we are working on
database
)

Return if this change should execute

public boolean
public boolean
supportsRollback(Database database)

Implements liquibase.change.Change.supportsRollback.

Implementation returns true if createInverses() returns a non-null value.

public String
toString()

Overrides liquibase.AbstractExtensibleObject.toString.

Returns a string representation of the object.

public ValidationErrors
validate(Database database)

Implements liquibase.change.Change.validate.

Implementation checks the ChangeParameterMetaData for declared required fields and also delegates logic to the liquibase.sqlgenerator.SqlGenerator#validate(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain) method on the SqlStatement objects returned by generateStatements.

public Warnings

Field Detail

changeSetback to summary
private ChangeSet changeSet
NODENAME_COLUMNback to summary
protected static final String NODENAME_COLUMN

Constructor Detail

AbstractChangeback to summary
public AbstractChange()

Method Detail

checkStatusback to summary
public ChangeStatus checkStatus(Database database)

Implements liquibase.change.Change.checkStatus.

Doc from liquibase.change.Change.checkStatus.

Validate that this change executed successfully against the given database. This will check that the update completed at a high level plus check details of the change. For example, a change to add a column will check that the column exists plus data type, default values, etc.

Annotations
@Override
createChangeMetaDataback to summary
public ChangeMetaData createChangeMetaData()

Implements liquibase.change.Change.createChangeMetaData.

Generate the ChangeMetaData for this class. Default implementation reads from the @DatabaseChange annotation and calls out to createChangeParameterMetadata(String) for each property.

Annotations
@Override
Exceptions
UnexpectedLiquibaseException:
if no @DatabaseChange annotation on this Change class
createChangeParameterMetadataback to summary
protected ChangeParameterMetaData createChangeParameterMetadata(String parameterName)

Called by createChangeMetaData() to create metadata for a given parameter. It finds the method that corresponds to the parameter and calls the corresponding create*MetaData methods such as createRequiredDatabasesMetaData(String, DatabaseChangeProperty) to determine the correct values for the ChangeParameterMetaData fields.

Exceptions
UnexpectedLiquibaseException:
if the passed parameter does not exist
createChangeParameterMetadataback to summary
private ChangeParameterMetaData createChangeParameterMetadata(PropertyDescriptor property, Method readMethod)
createDescriptionMetaDataback to summary
protected String createDescriptionMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "description" value. Uses the value on the DatabaseChangeProperty annotation or returns null as a default.

Annotations
@SuppressWarnings:UnusedParameters
createEmptyColumnConfigback to summary
protected ColumnConfig createEmptyColumnConfig(Class<T> collectionType) throws ReflectiveOperationException
createExampleValueMetaDataback to summary
protected Map<String, Object> createExampleValueMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "example" value. Uses the value on the DatabaseChangeProperty annotation or returns null as a default. Returns map with key=database short name, value=example. Use short-name "all" as the fallback.

Annotations
@SuppressWarnings:UnusedParameters
createInversesback to summary
protected Change[] createInverses()

Create inverse changes that can roll back this change. This method is intended to be overridden by Change implementations that have a logical inverse operation. Default implementation returns null.

If generateRollbackStatements(liquibase.database.Database) is overridden, this method may not be called.

Returns:Change[]

Return null if there is no corresponding inverse and therefore automatic rollback is not possible. Return an empty array to have a no-op rollback.

See Also
supportsRollback
createMustEqualExistingMetaDataback to summary
protected String createMustEqualExistingMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "mustEqual" value. Uses the value on the DatabaseChangeProperty annotation or returns null as a default.

Annotations
@SuppressWarnings:UnusedParameters
createRequiredDatabasesMetaDataback to summary
protected String[] createRequiredDatabasesMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "requiredDatabases" value. Uses the value on the DatabaseChangeProperty annotation or returns an array containing the string "COMPUTE" as a default. "COMPUTE" will cause ChangeParameterMetaData to attempt to determine the required databases based on the generated Statements

Annotations
@SuppressWarnings:UnusedParameters
createSerializationTypeMetaDataback to summary
protected LiquibaseSerializable.SerializationType createSerializationTypeMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "serializationType" value. Uses the value on the DatabaseChangeProperty annotation or returns liquibase.serializer.LiquibaseSerializable.SerializationType#NAMED_FIELD as a default.

Annotations
@SuppressWarnings:UnusedParameters
createSinceMetaDataback to summary
protected String createSinceMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "since" value. Uses the value on the DatabaseChangeProperty annotation or returns null as a default.

Annotations
@SuppressWarnings:UnusedParameters
createSupportedDatabasesMetaDataback to summary
protected String[] createSupportedDatabasesMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)

Create the ChangeParameterMetaData "supportedDatabase" value. Uses the value on the DatabaseChangeProperty annotation or returns an array containing the string "COMPUTE" as a default. "COMPUTE" will cause ChangeParameterMetaData to attempt to determine the required databases based on the generated Statements

Annotations
@SuppressWarnings:UnusedParameters
customLoadLogicback to summary
protected void customLoadLogic(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException
equalsback to summary
public boolean equals(Object reference)

Overrides liquibase.AbstractExtensibleObject.equals.

Doc from liquibase.AbstractExtensibleObject.equals.

Default implementation counts objects equal if their describe() methods return equal strings.

Parameters
reference:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
findDatabaseChangePropertyAnnotationMatchingCurrentChecksumVersionback to summary
private DatabaseChangeProperty findDatabaseChangePropertyAnnotationMatchingCurrentChecksumVersion(Method readMethod)

Given a particular method, find the DatabaseChangeProperty annotation on it that most precisely matches the requested checksum version. The logic can be summarized as follows: 1. If only one DatabaseChangeProperty annotation is on the particular method, then return it. 2. If no DatabaseChangeProperty annotations are present on the particular method, return null; 3. In the event that multiple DatabaseChangeProperty annotations are present on the particular method, read all of them to determine which one most closely matches the requested checksum version. If an annotation exists that specifies its version as the same version that is being requested, it is returned. If no annotation exists with a matching version, the first annotation on the method without a version is returned. If no annotations with no version exist, then null is returned.

finishInitializationback to summary
public void finishInitialization() throws SetupException

Implements liquibase.change.Change.finishInitialization.

Default implementation is a no-op

Annotations
@Override
generateCheckSumback to summary
public CheckSum generateCheckSum()

Implements liquibase.change.Change.generateCheckSum.

Implementation generates checksum by serializing the change with StringChangeLogSerializer

Annotations
@Override
generateRollbackStatementsback to summary
public SqlStatement[] generateRollbackStatements(Database database) throws RollbackImpossibleException

Implements liquibase.change.Change.generateRollbackStatements.

Implementation relies on value returned from createInverses().

Annotations
@Override
Exceptions
RollbackImpossibleException:

Doc from liquibase.change.Change.generateRollbackStatements.

if rollback is not supported for this change

generateRollbackStatementsFromInverseback to summary
private SqlStatement[] generateRollbackStatementsFromInverse(Database database) throws RollbackImpossibleException
generateRollbackStatementsVolatileback to summary
public boolean generateRollbackStatementsVolatile(Database database)

Implements liquibase.change.Change.generateRollbackStatementsVolatile.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#generateRollbackStatementsIsVolatile(Database) method on the SqlStatement objects returned by generateStatements If no or null SqlStatements are returned by generateRollbackStatements then this method returns false.

Annotations
@Override
generateStatementsVolatileback to summary
public boolean generateStatementsVolatile(Database database)

Implements liquibase.change.Change.generateStatementsVolatile.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#generateStatementsIsVolatile(Database) method on the SqlStatement objects returned by generateStatements. If zero or null SqlStatements are returned by generateStatements then this method returns false.

Annotations
@Override
getAffectedDatabaseObjectsback to summary
public Set<DatabaseObject> getAffectedDatabaseObjects(Database database)

Implements liquibase.change.Change.getAffectedDatabaseObjects.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGeneratorFactory#getAffectedDatabaseObjects(liquibase.statement.SqlStatement, liquibase.database.Database) method on the SqlStatement objects returned by generateStatements Returns empty set if change is not supported for the passed database

Annotations
@Override
getChangeSetback to summary
public ChangeSet getChangeSet()

Implements liquibase.change.Change.getChangeSet.

Doc from liquibase.change.Change.getChangeSet.

Returns the changeSet this Change is part of. Will return null if this instance was not constructed as part of a changelog file.

Annotations
@Override
@DatabaseChangeProperty
isChangeProperty:false
getDescriptionback to summary
public String getDescription()

Implements liquibase.change.Change.getDescription.

Doc from liquibase.change.Change.getDescription.

Short, scannable description for the DATABASECHANGELOG.DESCRIPTION column

Annotations
@Override
getExcludedFieldFiltersback to summary
public String[] getExcludedFieldFilters(ChecksumVersion version)
getResourceAccessorback to summary
public ResourceAccessor getResourceAccessor()

Deprecated

Should get from Scope

Annotations
@DatabaseChangeProperty
isChangeProperty:false
getSerializableFieldNamespaceback to summary
public String getSerializableFieldNamespace(String field)

Implements liquibase.serializer.LiquibaseSerializable.getSerializableFieldNamespace.

Annotations
@Override
getSerializableFieldsback to summary
public Set<String> getSerializableFields()

Implements liquibase.serializer.LiquibaseSerializable.getSerializableFields.

Returns the fields on this change that are serializable.

Annotations
@Override
getSerializableFieldTypeback to summary
public LiquibaseSerializable.SerializationType getSerializableFieldType(String field)

Implements liquibase.serializer.LiquibaseSerializable.getSerializableFieldType.

Annotations
@Override
getSerializableFieldValueback to summary
public Object getSerializableFieldValue(String field)

Implements liquibase.serializer.LiquibaseSerializable.getSerializableFieldValue.

Annotations
@Override
getSerializedObjectNameback to summary
public String getSerializedObjectName()

Implements liquibase.serializer.LiquibaseSerializable.getSerializedObjectName.

Annotations
@Override
getSerializedObjectNamespaceback to summary
public String getSerializedObjectNamespace()

Implements liquibase.serializer.LiquibaseSerializable.getSerializedObjectNamespace.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides liquibase.AbstractExtensibleObject.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isInvalidPropertyback to summary
protected boolean isInvalidProperty(PropertyDescriptor property)
loadback to summary
public void load(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException

Implements liquibase.serializer.LiquibaseSerializable.load.

Annotations
@Override
modifyback to summary
public void modify(ChangeVisitor changeVisitor) throws ParsedNodeException

Implements liquibase.change.Change.modify.

Annotations
@Override
Exceptions
ParsedNodeException:

Doc from liquibase.change.Change.modify.

if there is an error processing ChangeVisitor

serializeback to summary
public ParsedNode serialize() throws ParsedNodeException

Implements liquibase.serializer.LiquibaseSerializable.serialize.

Annotations
@Override
serializeValueback to summary
protected Object serializeValue(Object value) throws ParsedNodeException
setChangeSetback to summary
public void setChangeSet(ChangeSet changeSet)

Implements liquibase.change.Change.setChangeSet.

Doc from liquibase.change.Change.setChangeSet.

Sets the changeSet this Change is a part of. Called automatically by Liquibase during the changelog parsing process.

Annotations
@Override
setResourceAccessorback to summary
public void setResourceAccessor(ResourceAccessor resourceAccessor)

Implements liquibase.change.Change.setResourceAccessor.

Doc from liquibase.change.Change.setResourceAccessor.

Sets the ResourceAccessor that should be used for any file and/or resource loading needed by this Change. Called automatically by Liquibase during the changelog parsing process.

Annotations
@Override
shouldExecuteChangeback to summary
public boolean shouldExecuteChange(Database database)

Return if this change should execute

Parameters
database:Database

Database we are working on

Returns:boolean

boolean

supportsback to summary
public boolean supports(Database database)

Implements liquibase.change.Change.supports.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#supports(liquibase.statement.SqlStatement, liquibase.database.Database) method on the SqlStatement objects returned by generateStatements. If no or null SqlStatements are returned by generateStatements then this method returns true. If generateStatementsVolatile(liquibase.database.Database) returns true, we cannot call generateStatements and so assume true.

Annotations
@Override
supportsRollbackback to summary
public boolean supportsRollback(Database database)

Implements liquibase.change.Change.supportsRollback.

Implementation returns true if createInverses() returns a non-null value.

Annotations
@Override
toStringback to summary
public String toString()

Overrides liquibase.AbstractExtensibleObject.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
validateback to summary
public ValidationErrors validate(Database database)

Implements liquibase.change.Change.validate.

Implementation checks the ChangeParameterMetaData for declared required fields and also delegates logic to the liquibase.sqlgenerator.SqlGenerator#validate(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain) method on the SqlStatement objects returned by generateStatements. If no or null SqlStatements are returned by generateStatements then this method returns no errors. If there are no parameters than this method returns no errors

Annotations
@Override
warnback to summary
public Warnings warn(Database database)

Implements liquibase.change.Change.warn.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#warn(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain) method on the SqlStatement objects returned by generateStatements. If a generated statement is not supported for the given database, no warning will be added since that is a validation error. If no or null SqlStatements are returned by generateStatements then this method returns no warnings.

Annotations
@Override