Class AddForeignKeyConstraintChange

All Implemented Interfaces:
Cloneable, Change, ExtensibleObject, Plugin, LiquibaseSerializable

public class AddForeignKeyConstraintChange extends AbstractChange
Adds a foreign key constraint to an existing column.
  • Constructor Details

    • AddForeignKeyConstraintChange

      public AddForeignKeyConstraintChange()
  • Method Details

    • createSupportedDatabasesMetaData

      protected String[] createSupportedDatabasesMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)
      Description copied from class: AbstractChange
      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
      Overrides:
      createSupportedDatabasesMetaData in class AbstractChange
    • getBaseTableCatalogName

      public String getBaseTableCatalogName()
    • setBaseTableCatalogName

      public void setBaseTableCatalogName(String baseTableCatalogName)
    • getBaseTableSchemaName

      public String getBaseTableSchemaName()
    • setBaseTableSchemaName

      public void setBaseTableSchemaName(String baseTableSchemaName)
    • getBaseTableName

      public String getBaseTableName()
    • setBaseTableName

      public void setBaseTableName(String baseTableName)
    • getBaseColumnNames

      public String getBaseColumnNames()
    • setBaseColumnNames

      public void setBaseColumnNames(String baseColumnNames)
    • getReferencedTableCatalogName

      public String getReferencedTableCatalogName()
    • setReferencedTableCatalogName

      public void setReferencedTableCatalogName(String referencedTableCatalogName)
    • getReferencedTableSchemaName

      public String getReferencedTableSchemaName()
    • setReferencedTableSchemaName

      public void setReferencedTableSchemaName(String referencedTableSchemaName)
    • getReferencedTableName

      public String getReferencedTableName()
    • setReferencedTableName

      public void setReferencedTableName(String referencedTableName)
    • getReferencedColumnNames

      public String getReferencedColumnNames()
    • setReferencedColumnNames

      public void setReferencedColumnNames(String referencedColumnNames)
    • getConstraintName

      public String getConstraintName()
    • setConstraintName

      public void setConstraintName(String constraintName)
    • getDeferrable

      public Boolean getDeferrable()
    • setDeferrable

      public void setDeferrable(Boolean deferrable)
    • getInitiallyDeferred

      public Boolean getInitiallyDeferred()
    • setInitiallyDeferred

      public void setInitiallyDeferred(Boolean initiallyDeferred)
    • getValidate

      public Boolean getValidate()
      the VALIDATE keyword defines whether to check if a foreign key constraint on a column in a table refers to a valid row or not.
      Returns:
      true if ENABLE VALIDATE (this is the default), or false if ENABLE NOVALIDATE.
    • setValidate

      public void setValidate(Boolean shouldValidate)
      Parameters:
      shouldValidate - - 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 foreign keys - only new data would be checked to see if it complies with the constraint logic. The default state for foreign keys is to have 'ENABLE VALIDATE' set.
    • getDeleteCascade

      @Deprecated public Boolean getDeleteCascade()
      Deprecated.
      Use getOnDelete(). This always returns null so it doesn't impact checksums when settings onDelete vs. deleteCascade
    • setDeleteCascade

      public void setDeleteCascade(Boolean deleteCascade)
    • setOnUpdate

      public void setOnUpdate(String rule)
    • getOnUpdate

      public String getOnUpdate()
    • getOnDelete

      public String getOnDelete()
    • setOnDelete

      public void setOnDelete(String onDelete)
    • setOnDelete

      public void setOnDelete(ForeignKeyConstraintType rule)
    • setOnUpdate

      public void setOnUpdate(ForeignKeyConstraintType rule)
    • generateStatements

      public SqlStatement[] generateStatements(Database database)
      Description copied from interface: Change
      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 Change.generateStatementsVolatile(liquibase.database.Database).
    • createInverses

      protected Change[] createInverses()
      Description copied from class: AbstractChange
      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 AbstractChange.generateRollbackStatements(liquibase.database.Database) is overridden, this method may not be called.

      Overrides:
      createInverses in class AbstractChange
      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.
      See Also:
    • checkStatus

      public ChangeStatus checkStatus(Database database)
      Description copied from interface: Change
      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.
      Specified by:
      checkStatus in interface Change
      Overrides:
      checkStatus in class AbstractChange
    • getConfirmationMessage

      public String getConfirmationMessage()
      Description copied from interface: Change
      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.
    • getReferencesUniqueColumn

      @Deprecated public Boolean getReferencesUniqueColumn()
      Deprecated.
      No longer supported in 3.0
    • setReferencesUniqueColumn

      public void setReferencesUniqueColumn(Boolean referencesUniqueColumn)
    • getSerializedObjectNamespace

      public String getSerializedObjectNamespace()
      Specified by:
      getSerializedObjectNamespace in interface LiquibaseSerializable
      Overrides:
      getSerializedObjectNamespace in class AbstractChange