Class GeneratedColumnChange

  • All Implemented Interfaces:
    Cloneable, liquibase.change.Change, liquibase.change.ChangeWithColumns<AddGeneratedColumnConfig>, liquibase.ExtensibleObject, liquibase.plugin.Plugin, liquibase.serializer.LiquibaseSerializable

    public class GeneratedColumnChange
    extends liquibase.change.AbstractChange
    implements liquibase.change.ChangeWithColumns<AddGeneratedColumnConfig>
    Extension used to add generated column to the table. Value is either generated from a property of a JSON file stored in one of the table's columns or from hash value of existing column.

    Example configuration in the changelog:

         <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
                        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd
                        http://www.liquibase.org/xml/ns/dbchangelog-ext
                        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
    
         <changeSet author="keycloak" id="some_id">
             ...
             <ext:addGeneratedColumn tableName="test">
                 <ext:column name="new_column" type="VARCHAR(36)" jsonColumn="metadata" jsonProperty="alias"/>
             </ext:addGeneratedColumn>
         </changeSet>
     
    The above configuration is adding a new column, named new_column, whose values are generated from the alias property of the JSON file stored in column metadata. If, for example, a particular entry in the table contains the JSON {"name":"duke","alias":"jduke"} in column metadata, the value generated for the new column will be jduke.

    The configuration below adds new generated column named new_column with value being a hash of a column column. For more information about the type see KeycloakHashDataType.

     <changeSet author="keycloak" id="some_id">
         ...
         <ext:addGeneratedColumn tableName="test">
             <ext:column name="new_column" type="kc_hash" hashOf="column"/>
         </ext:addGeneratedColumn>
     </changeSet>
     
    Author:
    Stefan Guilhen
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface liquibase.serializer.LiquibaseSerializable

        liquibase.serializer.LiquibaseSerializable.SerializationType
    • Field Summary

      • Fields inherited from class liquibase.change.AbstractChange

        NODENAME_COLUMN
      • Fields inherited from interface liquibase.serializer.LiquibaseSerializable

        GENERIC_CHANGELOG_EXTENSION_NAMESPACE, GENERIC_SNAPSHOT_EXTENSION_NAMESPACE, STANDARD_CHANGELOG_NAMESPACE, STANDARD_SNAPSHOT_NAMESPACE
      • Fields inherited from interface liquibase.plugin.Plugin

        PRIORITY_DEFAULT, PRIORITY_NOT_APPLICABLE, PRIORITY_SPECIALIZED
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addColumn​(AddGeneratedColumnConfig column)  
      liquibase.change.ChangeStatus checkStatus​(liquibase.database.Database database)  
      protected liquibase.change.Change[] createInverses()  
      liquibase.statement.SqlStatement[] generateStatements​(liquibase.database.Database database)  
      String getCatalogName()  
      List<AddGeneratedColumnConfig> getColumns()  
      String getConfirmationMessage()  
      String getSchemaName()  
      String getSerializedObjectNamespace()  
      String getTableName()  
      void setCatalogName​(String catalogName)  
      void setColumns​(List<AddGeneratedColumnConfig> columns)  
      void setSchemaName​(String schemaName)  
      void setTableName​(String tableName)  
      liquibase.exception.ValidationErrors validate​(liquibase.database.Database database)  
      • Methods inherited from class liquibase.change.AbstractChange

        createChangeMetaData, createChangeParameterMetadata, createDescriptionMetaData, createEmptyColumnConfig, createExampleValueMetaData, createMustEqualExistingMetaData, createRequiredDatabasesMetaData, createSerializationTypeMetaData, createSinceMetaData, createSupportedDatabasesMetaData, customLoadLogic, finishInitialization, generateCheckSum, generateRollbackStatements, generateRollbackStatementsVolatile, generateStatementsVolatile, getAffectedDatabaseObjects, getChangeSet, getDescription, getResourceAccessor, getSerializableFieldNamespace, getSerializableFields, getSerializableFieldType, getSerializableFieldValue, getSerializedObjectName, isInvalidProperty, load, serialize, serializeValue, setChangeSet, setResourceAccessor, supports, supportsRollback, toString, warn
      • Methods inherited from class liquibase.AbstractExtensibleObject

        clone, describe, equals, get, get, get, getAttributes, getFieldValue, getObjectMetaData, getValuePath, has, hashCode, set
      • Methods inherited from interface liquibase.ExtensibleObject

        clone, describe, get, get, getAttributes, getObjectMetaData, getValuePath, has, set
    • Constructor Detail

      • GeneratedColumnChange

        public GeneratedColumnChange()
    • Method Detail

      • getCatalogName

        public String getCatalogName()
      • setCatalogName

        public void setCatalogName​(String catalogName)
      • getSchemaName

        public String getSchemaName()
      • setSchemaName

        public void setSchemaName​(String schemaName)
      • getTableName

        public String getTableName()
      • setTableName

        public void setTableName​(String tableName)
      • generateStatements

        public liquibase.statement.SqlStatement[] generateStatements​(liquibase.database.Database database)
        Specified by:
        generateStatements in interface liquibase.change.Change
      • createInverses

        protected liquibase.change.Change[] createInverses()
        Overrides:
        createInverses in class liquibase.change.AbstractChange
      • checkStatus

        public liquibase.change.ChangeStatus checkStatus​(liquibase.database.Database database)
        Specified by:
        checkStatus in interface liquibase.change.Change
        Overrides:
        checkStatus in class liquibase.change.AbstractChange
      • getConfirmationMessage

        public String getConfirmationMessage()
        Specified by:
        getConfirmationMessage in interface liquibase.change.Change
      • getSerializedObjectNamespace

        public String getSerializedObjectNamespace()
        Specified by:
        getSerializedObjectNamespace in interface liquibase.serializer.LiquibaseSerializable
        Overrides:
        getSerializedObjectNamespace in class liquibase.change.AbstractChange
      • validate

        public liquibase.exception.ValidationErrors validate​(liquibase.database.Database database)
        Specified by:
        validate in interface liquibase.change.Change
        Overrides:
        validate in class liquibase.change.AbstractChange