Top Description Inners Fields Constructors Methods
liquibase.change.core

public Class AddNotNullConstraintChange

extends AbstractChange
Class Inheritance
Annotations
@DatabaseChange
name:addNotNullConstraint
description:Adds a NOT NULL constraint to an existing table. If a defaultNullValue attribute is passed, all null values for the column will be updated to the passed value before the constraint is applied.
priority:1
appliesTo:column
Imports
liquibase.change.*, liquibase.database.Database, liquibase.database.core.DB2Database, .PostgresDatabase, .SQLiteDatabase.AlterTableVisitor, liquibase.datatype.DataTypeFactory, .LiquibaseDataType, liquibase.datatype.core.BooleanType, liquibase.statement.DatabaseFunction, .SqlStatement, liquibase.statement.core.ReorganizeTableStatement, .SetNullableStatement, .UpdateStatement, liquibase.structure.core.Column, .Index, liquibase.util.BooleanUtil, .StringUtil, java.util.ArrayList, .List

Adds a NOT NULL constraint to an existing column.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

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

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
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 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 certain SQL dialects, the VALIDATE keyword defines whether a NOT NULL constraint on a column in a table should be checked if it refers to a valid row or not.

public void
setCatalogName(String catalogName)

public void
setColumnDataType(String columnDataType)

public void
setColumnName(String columnName)

public void
setConstraintName(String constraintName)

public void
setDefaultNullValue(String defaultNullValue)

public void
setSchemaName(String schemaName)

public void
setTableName(String tableName)

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 not null constrain - only new data would be checked to see if it complies with the constraint logic. The default state for not null constrain is to have 'ENABLE VALIDATE' set.
shouldValidate
)

Inherited from liquibase.change.AbstractChange:
checkStatuscreateChangeMetaDatacreateChangeParameterMetadatacreateDescriptionMetaDatacreateEmptyColumnConfigcreateExampleValueMetaDatacreateMustEqualExistingMetaDatacreateRequiredDatabasesMetaDatacreateSerializationTypeMetaDatacreateSinceMetaDatacreateSupportedDatabasesMetaDatacustomLoadLogicequalsfinishInitializationgenerateCheckSumgenerateRollbackStatementsgenerateRollbackStatementsVolatilegenerateStatementsVolatilegetAffectedDatabaseObjectsgetChangeSetgetDescriptiongetExcludedFieldFiltersgetResourceAccessorgetSerializableFieldNamespacegetSerializableFieldsgetSerializableFieldTypegetSerializableFieldValuegetSerializedObjectNamehashCodeisInvalidPropertyloadmodifyserializeserializeValuesetChangeSetsetResourceAccessorshouldExecuteChangesupportssupportsRollbacktoStringvalidatewarn

Field Detail

catalogNameback to summary
private String catalogName
columnDataTypeback to summary
private String columnDataType
columnNameback to summary
private String columnName
constraintNameback to summary
private String constraintName
defaultNullValueback to summary
private String defaultNullValue
schemaNameback to summary
private String schemaName
shouldValidateback to summary
private Boolean shouldValidate
tableNameback to summary
private String tableName

Constructor Detail

AddNotNullConstraintChangeback to summary
public AddNotNullConstraintChange()

Method Detail

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
since:3.0
mustEqualExisting:column.relation.catalog
description:Name of the database catalog
getColumnDataTypeback to summary
public String getColumnDataType()
Annotations
@DatabaseChangeProperty
description:Current data type of the column
getColumnNameback to summary
public String getColumnName()
Annotations
@DatabaseChangeProperty
description:Name of the column to add the constraint to
mustEqualExisting:column.relation.column
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 constraint to add (if database supports names for NOT NULL constraints)
getDefaultNullValueback to summary
public String getDefaultNullValue()
Annotations
@DatabaseChangeProperty
description:Value to set all currently null values to. If defaultNullValue is not set and null values exist, the change fails
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
description:Name of the table to add a NOT NULL constraint to.
mustEqualExisting:column.relation
getValidateback to summary
public Boolean getValidate()

In certain SQL dialects, the VALIDATE keyword defines whether a NOT NULL constraint on a column in a table should be checked if it refers to a valid row 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 NOT NULL 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)
setColumnDataTypeback to summary
public void setColumnDataType(String columnDataType)
setColumnNameback to summary
public void setColumnName(String columnName)
setConstraintNameback to summary
public void setConstraintName(String constraintName)
setDefaultNullValueback to summary
public void setDefaultNullValue(String defaultNullValue)
setSchemaNameback to summary
public void setSchemaName(String schemaName)
setTableNameback to summary
public void setTableName(String tableName)
setValidateback to summary
public void setValidate(Boolean shouldValidate)
Parameters
shouldValidate: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 not null constrain - only new data would be checked to see if it complies with the constraint logic. The default state for not null constrain is to have 'ENABLE VALIDATE' set.

liquibase.change.core back to summary

pack-priv Class AddNotNullConstraintChange.SQLiteAlterTableVisitor

extends Object
implements AlterTableVisitor
Class Inheritance
  • java.lang.Object
  • liquibase.change.core.AddNotNullConstraintChange.SQLiteAlterTableVisitor
All Implemented Interfaces
liquibase.database.core.SQLiteDatabase.AlterTableVisitor

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
public boolean
public ColumnConfig[]
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SQLiteAlterTableVisitorback to summary
pack-priv SQLiteAlterTableVisitor()

Method Detail

copyThisColumnback to summary
public boolean copyThisColumn(ColumnConfig column)

Implements liquibase.database.core.SQLiteDatabase.AlterTableVisitor.copyThisColumn.

Annotations
@Override
createThisColumnback to summary
public boolean createThisColumn(ColumnConfig column)

Implements liquibase.database.core.SQLiteDatabase.AlterTableVisitor.createThisColumn.

Annotations
@Override
createThisIndexback to summary
public boolean createThisIndex(Index index)

Implements liquibase.database.core.SQLiteDatabase.AlterTableVisitor.createThisIndex.

Annotations
@Override
getColumnsToAddback to summary
public ColumnConfig[] getColumnsToAdd()

Implements liquibase.database.core.SQLiteDatabase.AlterTableVisitor.getColumnsToAdd.

Annotations
@Override