Top Description Fields Constructors Methods
liquibase.change.core

public Class AddUniqueConstraintChange

extends AbstractChange
Class Inheritance
Annotations
@DatabaseChange
name:addUniqueConstraint
description:Adds a unique constraint to an existing column or set of columns.
priority:1
appliesTo:column
Imports
liquibase.change.*, liquibase.database.Database, liquibase.snapshot.SnapshotGeneratorFactory, liquibase.statement.SqlStatement, liquibase.statement.core.AddUniqueConstraintStatement, liquibase.structure.core.Column, .UniqueConstraint

Adds a unique constraint to an existing column.

Field Summary

Modifier and TypeField and Description
private String
private Boolean
private String
private String
private Boolean
private Boolean
private String
private String
private String
private Boolean
private String
private Boolean
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 AddUniqueConstraintStatement
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 Boolean
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 Boolean
public String
public String
public String
public Boolean
public String
public String
public String
public String
public Boolean

Returns:

true if ENABLE VALIDATE (this is the default), or false if ENABLE NOVALIDATE.
getValidate
()

In Oracle PL/SQL, the VALIDATE keyword defines whether a newly added unique constraint on a column in a table should cause existing rows to be checked to see if they satisfy the uniqueness constraint or not.

public void
setCatalogName(String catalogName)

public void
setClustered(Boolean clustered)

public void
setColumnNames(String columnNames)

public void
setConstraintName(String constraintName)

public void
setDeferrable(Boolean deferrable)

public void
setDisabled(Boolean disabled)

public void
setForIndexCatalogName(String forIndexCatalogName)

public void
setForIndexName(String forIndexName)

public void
setForIndexSchemaName(String forIndexSchemaName)

public void
setInitiallyDeferred(Boolean initiallyDeferred)

public void
setSchemaName(String schemaName)

public void
setTableName(String tableName)

public void
setTablespace(String tablespace)

public void
setValidate(Boolean
- if shouldValidate is set to FALSE then the constraint will be created with the 'ENABLE NOVALIDATE' mode. This means the constraint would be created, but that no check will be done to ensure old data has valid constraints - only new data would be checked to see if it complies with the constraint logic. The default state for unique constraints is to have 'ENABLE VALIDATE' set.
validate
)

Inherited from liquibase.change.AbstractChange:
createChangeMetaDatacreateChangeParameterMetadatacreateDescriptionMetaDatacreateEmptyColumnConfigcreateExampleValueMetaDatacreateMustEqualExistingMetaDatacreateRequiredDatabasesMetaDatacreateSerializationTypeMetaDatacreateSinceMetaDatacreateSupportedDatabasesMetaDatacustomLoadLogicequalsfinishInitializationgenerateCheckSumgenerateRollbackStatementsgenerateRollbackStatementsVolatilegenerateStatementsVolatilegetAffectedDatabaseObjectsgetChangeSetgetDescriptiongetExcludedFieldFiltersgetResourceAccessorgetSerializableFieldNamespacegetSerializableFieldsgetSerializableFieldTypegetSerializableFieldValuegetSerializedObjectNamehashCodeisInvalidPropertyloadmodifyserializeserializeValuesetChangeSetsetResourceAccessorshouldExecuteChangesupportssupportsRollbacktoStringvalidatewarn

Field Detail

catalogNameback to summary
private String catalogName
clusteredback to summary
private Boolean clustered
columnNamesback to summary
private String columnNames
constraintNameback to summary
private String constraintName
deferrableback to summary
private Boolean deferrable
disabledback to summary
private Boolean disabled
forIndexCatalogNameback to summary
private String forIndexCatalogName
forIndexNameback to summary
private String forIndexName
forIndexSchemaNameback to summary
private String forIndexSchemaName
initiallyDeferredback to summary
private Boolean initiallyDeferred
schemaNameback to summary
private String schemaName
shouldValidateback to summary
private Boolean shouldValidate
tableNameback to summary
private String tableName
tablespaceback to summary
private String tablespace

Constructor Detail

AddUniqueConstraintChangeback to summary
public AddUniqueConstraintChange()

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
createAddUniqueConstraintStatementback to summary
protected AddUniqueConstraintStatement createAddUniqueConstraintStatement()
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
getClusteredback to summary
public Boolean getClustered()
Annotations
@DatabaseChangeProperty
description:Whether to create a clustered index
getColumnNamesback to summary
public String getColumnNames()
Annotations
@DatabaseChangeProperty
mustEqualExisting:column
description:Name of the column(s) to create the unique constraint on. Comma separated if multiple
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
getConstraintNameback to summary
public String getConstraintName()
Annotations
@DatabaseChangeProperty
description:Name of the unique constraint
getDeferrableback to summary
public Boolean getDeferrable()
Annotations
@DatabaseChangeProperty
description:Defines whether the constraint is deferrable
getDisabledback to summary
public Boolean getDisabled()
Annotations
@DatabaseChangeProperty
description:Specifies whether the constraint is disabled
getForIndexCatalogNameback to summary
public String getForIndexCatalogName()
Annotations
@DatabaseChangeProperty
description:Name of the catalog of the index to associate with the constraint
getForIndexNameback to summary
public String getForIndexName()
Annotations
@DatabaseChangeProperty
description:Name of the index to associate with the constraint
getForIndexSchemaNameback to summary
public String getForIndexSchemaName()
Annotations
@DatabaseChangeProperty
description:Name of the schema of the index to associate with the constraint
getInitiallyDeferredback to summary
public Boolean getInitiallyDeferred()
Annotations
@DatabaseChangeProperty
description:Defines whether the constraint is initially deferred
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 to create the unique constraint on
getTablespaceback to summary
public String getTablespace()
Annotations
@DatabaseChangeProperty
description:Tablespace to create the index in. Corresponds to file group in mssql
getValidateback to summary
public Boolean getValidate()

In Oracle PL/SQL, the VALIDATE keyword defines whether a newly added unique constraint on a column in a table should cause existing rows to be checked to see if they satisfy the uniqueness constraint or not.

Returns:Boolean

true if ENABLE VALIDATE (this is the default), or false if ENABLE NOVALIDATE.

Annotations
@DatabaseChangeProperty
description:Defines whether to check if the unique constraint refers to a valid row. This is true if the constraint has \'ENABLE VALIDATE\' set, or false if the constraint has \'ENABLE NOVALIDATE\' set.
setCatalogNameback to summary
public void setCatalogName(String catalogName)
setClusteredback to summary
public void setClustered(Boolean clustered)
setColumnNamesback to summary
public void setColumnNames(String columnNames)
setConstraintNameback to summary
public void setConstraintName(String constraintName)
setDeferrableback to summary
public void setDeferrable(Boolean deferrable)
setDisabledback to summary
public void setDisabled(Boolean disabled)
setForIndexCatalogNameback to summary
public void setForIndexCatalogName(String forIndexCatalogName)
setForIndexNameback to summary
public void setForIndexName(String forIndexName)
setForIndexSchemaNameback to summary
public void setForIndexSchemaName(String forIndexSchemaName)
setInitiallyDeferredback to summary
public void setInitiallyDeferred(Boolean initiallyDeferred)
setSchemaNameback to summary
public void setSchemaName(String schemaName)
setTableNameback to summary
public void setTableName(String tableName)
setTablespaceback to summary
public void setTablespace(String tablespace)
setValidateback to summary
public void setValidate(Boolean validate)
Parameters
validate:Boolean

- if shouldValidate is set to FALSE then the constraint will be created with the 'ENABLE NOVALIDATE' mode. This means the constraint would be created, but that no check will be done to ensure old data has valid constraints - only new data would be checked to see if it complies with the constraint logic. The default state for unique constraints is to have 'ENABLE VALIDATE' set.