addAttribute

The addAttributes tag specifies information about attributes you create with the alterCompositeTypeAttributes change type.

Note: Inspection features or commands, such as snapshot, diff, generate-changelog, and diff-changelog, are not currently supported with composite types.

Available attributes

Name Type Description Requirement
name String Name of the composite type attribute to be created Required
type String Name of the type the attribute will be associated with Required
collation String Name of an existing collation to be associated with a column of a composite type, or with a range type Optional
onCreate String Set to CASCADE or RESTRICT. CASCADE automatically updates objects that depend on the type. RESTRICT does not updatethe type if any objects depend on it. Default: RESTRICT. Optional

Examples

databaseChangeLog:
  - changeSet:
      id: 1
      author: itTest
      changes:
        - createCompositeType:
            typeName: "myType"
            typeAttributes:
              - typeAttribute:
                  name: "attr0"
                  type: "int"
              - typeAttribute:
                  name: "attr1"
                  type: "int"
              - typeAttribute:
                  name: "attr2"
                  type: "int"
  - changeSet:
      id: 2
      author: itTest
      changes:
        - alterCompositeTypeAttributes:
            typeName: "myType"
            addAttributes:
              - addAttribute:
                  name: "attr3"
                  type: "text"
                  collation: "en_US"
                  onCreate: "CASCADE"

      rollback:
        - empty
{
  "databaseChangeLog": [
    {
      "changeSet": {
        "id": "1",
        "author": "itTest",
        "changes": [
          {
            "createCompositeType": {
              "typeName": "myType",
              "typeAttributes": [
                {
                  "typeAttribute": {
                    "name": "attr0",
                    "type": "int"
                  }
                },
                {
                  "typeAttribute": {
                    "name": "attr1",
                    "type": "int"
                  }
                },
                {
                  "typeAttribute": {
                    "name": "attr2",
                    "type": "int"
                  }
                }
              ]
            }
          }
        ]
      }
    },
    {
      "changeSet": {
        "id": "2",
        "author": "itTest",
        "changes": [
          {
            "alterCompositeTypeAttributes": {
              "typeName": "myType",
              "addAttributes": [
                {
                  "addAttribute": {
                    "name": "attr3",
                    "type": "text",
                    "collation": "en_US",
                    "onCreate": "CASCADE"
                  }
                }
              ]
            }
          }
        ],
        "rollback": []
      }
    }
  ]
}
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:pro="http://www.liquibase.org/xml/ns/pro"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
         http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
    <changeSet author="itTest" id="1">
        <pro:createCompositeType typeName="myType">
            <pro:typeAttribute name="attr0" type="int"/>
            <pro:typeAttribute name="attr1" type="int"/>
            <pro:typeAttribute name="attr2" type="int"/>
        </pro:createCompositeType>
    </changeSet>
    <changeSet author="itTest" id="2">
        <pro:alterCompositeTypeAttributes typeName="myType">
            <pro:addAttribute name="attr3" type="text" collation="en_US" onCreate="CASCADE"/>
        </pro:alterCompositeTypeAttributes>
        <rollback/>
    </changeSet>
</databaseChangeLog>

Database Support

This change type is only supported for PostgreSQL.