Top Description Fields Constructors Methods
liquibase.change.core

public Class AddDefaultValueChange

extends AbstractChange
Class Inheritance
Annotations
@DatabaseChange
name:addDefaultValue
description:Adds a default value to the database definition for the specified column. One of defaultValue, defaultValueNumeric, defaultValueBoolean or defaultValueDate must be set
priority:1
appliesTo:column
Imports
java.text.NumberFormat, .ParseException, java.util.Date, .Locale, liquibase.change.AbstractChange, .Change, .ChangeMetaData, .ChangeStatus, .DatabaseChange, .DatabaseChangeProperty, liquibase.database.Database, liquibase.exception.ValidationErrors, liquibase.snapshot.SnapshotGeneratorFactory, liquibase.statement.DatabaseFunction, .SequenceNextValueFunction, .SqlStatement, liquibase.statement.core.AddDefaultValueStatement, liquibase.structure.core.Column, .Table, liquibase.util.ISODateFormat

Sets a new default value to an existing column.

Field Summary

Modifier and TypeField and Description
private String
private String
private String
private String
private Boolean
private DatabaseFunction
private String
private String
private String
private SequenceNextValueFunction
private String
private String
Inherited from liquibase.change.AbstractChange:
NODENAME_COLUMN

Constructor Summary

AccessConstructor and Description
public

Method Summary

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

Overrides liquibase.change.AbstractChange.checkStatus.

Implements liquibase.change.Change.checkStatus.

Validate that this change executed successfully against the given database.

protected Change[]
createInverses()

Overrides liquibase.change.AbstractChange.createInverses.

Create inverse changes that can roll back this change.

public SqlStatement[]
generateStatements(Database database)

Implements liquibase.change.Change.generateStatements.

Generates the SqlStatement objects required to run the change for the given database.

public String
public String
public String
public String
getConfirmationMessage()

Implements liquibase.change.Change.getConfirmationMessage.

Confirmation message to be displayed after the change is executed.

public String
public Boolean
public DatabaseFunction
public String
public String
public String
public SequenceNextValueFunction
public String
public String
public String
public void
setCatalogName(String catalogName)

public void
setColumnDataType(String columnDataType)

public void
setColumnName(String columnName)

public void
setDefaultValue(String defaultValue)

public void
setDefaultValueBoolean(Boolean defaultValueBoolean)

public void
public void
setDefaultValueConstraintName(String defaultValueConstraintName)

public void
setDefaultValueDate(String defaultValueDate)

public void
setDefaultValueNumeric(String defaultValueNumeric)

public void
public void
setSchemaName(String schemaName)

public void
setTableName(String tableName)

public ValidationErrors
validate(Database database)

Overrides liquibase.change.AbstractChange.validate.

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.

Inherited from liquibase.change.AbstractChange:
createChangeMetaDatacreateChangeParameterMetadatacreateDescriptionMetaDatacreateEmptyColumnConfigcreateExampleValueMetaDatacreateMustEqualExistingMetaDatacreateRequiredDatabasesMetaDatacreateSerializationTypeMetaDatacreateSinceMetaDatacreateSupportedDatabasesMetaDatacustomLoadLogicequalsfinishInitializationgenerateCheckSumgenerateRollbackStatementsgenerateRollbackStatementsVolatilegenerateStatementsVolatilegetAffectedDatabaseObjectsgetChangeSetgetDescriptiongetExcludedFieldFiltersgetResourceAccessorgetSerializableFieldNamespacegetSerializableFieldsgetSerializableFieldTypegetSerializableFieldValuegetSerializedObjectNamehashCodeisInvalidPropertyloadmodifyserializeserializeValuesetChangeSetsetResourceAccessorshouldExecuteChangesupportssupportsRollbacktoStringwarn

Field Detail

catalogNameback to summary
private String catalogName
columnDataTypeback to summary
private String columnDataType
columnNameback to summary
private String columnName
defaultValueback to summary
private String defaultValue
defaultValueBooleanback to summary
private Boolean defaultValueBoolean
defaultValueComputedback to summary
private DatabaseFunction defaultValueComputed
defaultValueConstraintNameback to summary
private String defaultValueConstraintName
defaultValueDateback to summary
private String defaultValueDate
defaultValueNumericback to summary
private String defaultValueNumeric
defaultValueSequenceNextback to summary
private SequenceNextValueFunction defaultValueSequenceNext
schemaNameback to summary
private String schemaName
tableNameback to summary
private String tableName

Constructor Detail

AddDefaultValueChangeback to summary
public AddDefaultValueChange()

Method Detail

checkStatusback to summary
public ChangeStatus checkStatus(Database database)

Overrides liquibase.change.AbstractChange.checkStatus.

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
createInversesback to summary
protected Change[] createInverses()

Overrides liquibase.change.AbstractChange.createInverses.

Doc from liquibase.change.AbstractChange.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.

Annotations
@Override
generateStatementsback to summary
public SqlStatement[] generateStatements(Database database)

Implements liquibase.change.Change.generateStatements.

Doc from liquibase.change.Change.generateStatements.

Generates the SqlStatement objects required to run the change for the given database.

NOTE: This method may be called multiple times throughout the changelog execution process and may be called in documentation generation and other integration points as well.

If this method reads from the current database state or uses any other logic that will be affected by whether previous changeSets have ran or not, you must return true from generateStatementsVolatile.
Annotations
@Override
getCatalogNameback to summary
public String getCatalogName()
Annotations
@DatabaseChangeProperty
mustEqualExisting:column.relation.catalog
since:3.0
description:Name of the database catalog
getColumnDataTypeback to summary
public String getColumnDataType()
Annotations
@DatabaseChangeProperty
description:Current data type of the column to add a default value to
exampleValue:varchar(50)
getColumnNameback to summary
public String getColumnName()
Annotations
@DatabaseChangeProperty
mustEqualExisting:column
description:Name of the column to add a default value to
exampleValue:fileName
getConfirmationMessageback to summary
public String getConfirmationMessage()

Implements liquibase.change.Change.getConfirmationMessage.

Doc from liquibase.change.Change.getConfirmationMessage.

Confirmation message to be displayed after the change is executed. Should include relevant configuration settings to make it as helpful as possible. This method may be called outside the changelog execution process, such as in documentation generation.

Annotations
@Override
getDefaultValueback to summary
public String getDefaultValue()
Annotations
@DatabaseChangeProperty
exampleValue:Something Else
requiredForDatabase:none
description:Default value for fields in the column. Either this property or another defaultValue* property is required.
getDefaultValueBooleanback to summary
public Boolean getDefaultValueBoolean()
Annotations
@DatabaseChangeProperty
requiredForDatabase:none
description:Default value for a column of a boolean type.
getDefaultValueComputedback to summary
public DatabaseFunction getDefaultValueComputed()
Annotations
@DatabaseChangeProperty
requiredForDatabase:none
description:Default value that is returned from a function or procedure call of the same type as the column. Contains the function or column name to call. Differs from defaultValue by returning the value of the function or column you specify instead of the name of the function/column as a string. Can also perform operations on the returned value.
getDefaultValueConstraintNameback to summary
public String getDefaultValueConstraintName()
Annotations
@DatabaseChangeProperty
description:Sets a unique name for the default constraint used for a specific column. Works only along with any of the defaultValue* properties listed.
getDefaultValueDateback to summary
public String getDefaultValueDate()
Annotations
@DatabaseChangeProperty
requiredForDatabase:none
exampleValue:2008-02-12T12:34:03
description:Default date and time value for column. The value is specified in one of the following forms: YYYY-MM-DD, hh:mm:ss, or YYYY-MM-DDThh:mm:ss.
getDefaultValueNumericback to summary
public String getDefaultValueNumeric()
Annotations
@DatabaseChangeProperty
requiredForDatabase:none
exampleValue:439.2
description:Default value for a column of a numeric type. For example: integer, bigint, bigdecimal, and others.
getDefaultValueSequenceNextback to summary
public SequenceNextValueFunction getDefaultValueSequenceNext()
Annotations
@DatabaseChangeProperty
requiredForDatabase:none
description:Sets value for a specified column by using the value of the existing sequence. With every new input, the next value of the sequence will be taken.
getSchemaNameback to summary
public String getSchemaName()
Annotations
@DatabaseChangeProperty
mustEqualExisting:column.relation.schema
description:Name of the database schema
getSerializedObjectNamespaceback to summary
public String getSerializedObjectNamespace()

Overrides liquibase.change.AbstractChange.getSerializedObjectNamespace.

Implements liquibase.serializer.LiquibaseSerializable.getSerializedObjectNamespace.

Annotations
@Override
getTableNameback to summary
public String getTableName()
Annotations
@DatabaseChangeProperty
mustEqualExisting:column.relation
description:Name of the table containing the column to modify
exampleValue:file
setCatalogNameback to summary
public void setCatalogName(String catalogName)
setColumnDataTypeback to summary
public void setColumnDataType(String columnDataType)
setColumnNameback to summary
public void setColumnName(String columnName)
setDefaultValueback to summary
public void setDefaultValue(String defaultValue)
setDefaultValueBooleanback to summary
public void setDefaultValueBoolean(Boolean defaultValueBoolean)
setDefaultValueComputedback to summary
public void setDefaultValueComputed(DatabaseFunction defaultValueComputed)
setDefaultValueConstraintNameback to summary
public void setDefaultValueConstraintName(String defaultValueConstraintName)
setDefaultValueDateback to summary
public void setDefaultValueDate(String defaultValueDate)
setDefaultValueNumericback to summary
public void setDefaultValueNumeric(String defaultValueNumeric)
setDefaultValueSequenceNextback to summary
public void setDefaultValueSequenceNext(SequenceNextValueFunction defaultValueSequenceNext)
setSchemaNameback to summary
public void setSchemaName(String schemaName)
setTableNameback to summary
public void setTableName(String tableName)
validateback to summary
public ValidationErrors validate(Database database)

Overrides liquibase.change.AbstractChange.validate.

Implements liquibase.change.Change.validate.

Doc from liquibase.change.AbstractChange.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