renameCompositeTypeAttribute

The renameCompositeTypeAttribute change type allows you to change the name of an attribute that is inside of a user-defined composite type. When you rename a composite type attribute, you are updating the type structure without changing the type's name or fields.

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

Run renameCompositeTypeAttribute

To run this Change Type, follow these steps:

  1. Add the Change Type to your changeset, as shown in the examples on this page.
  2. Specify any required attributes. Use the table on this page to see which ones your database requires.
  3. Deploy your changeset by running the update command:
  4. liquibase update

Available attributes

Name Type Description Requirement
catalogName String Name of the catalog Optional
schemaName String Name of the schema that contains the composite type you want to rename Optional
typeName String Name of the type that contains the attribute you want to rename Required
oldAttributeName String Name of the attribute that you no longer want to use Required
newAttributeName String Name of the new attribute that you want to use Required
onUpdate String Set to CASCADE or RESTRICT. CASCADE automatically updates objects that depend on the type. RESTRICT does not update the type if any objects depend on it. Default: RESTRICT. Optional

Examples

databaseChangeLog:
  - changeSet:
      id: 1
      author: itTest
      changes:
        - createCompositeType:
            typeName: "myType"
            typeAttributes:
              - typeAttribute:
                  name: "attr1"
                  type: "int"
              - typeAttribute:
                  name: "attr2"
                  type: "text"
                  collation: "en_US"
              - typeAttribute:
                  name: "Attr3"
                  type: "real"
              - typeAttribute:
                  name: "ATTR4"
                  type: "line"
        - renameCompositeTypeAttribute:
            typeName: "myType"
            oldAttributeName: "attr1"
            newAttributeName: "att®1"
            onUpdate: "CASCADE"
        - renameCompositeTypeAttribute:
            typeName: "myType"
            oldAttributeName: "attr2"
            newAttributeName: "attribute 2"
            onUpdate: "CASCADE"
        - renameCompositeTypeAttribute:
            typeName: "myType"
            oldAttributeName: "Attr3"
            newAttributeName: "AtTrIbUtE3"
            onUpdate: "CASCADE"
        - renameCompositeTypeAttribute:
            typeName: "myType"
            oldAttributeName: "ATTR4"
            newAttributeName: "attr & 4"
            onUpdate: "CASCADE"
{
  "databaseChangeLog": [
    {
      "changeSet": {
        "id": "1",
        "author": "itTest",
        "changes": [
          {
            "createCompositeType": {
              "typeName":"myType",
              "typeAttributes": [
                {
                  "typeAttribute": {
                    "name": "attr1",
                    "type": "int"
                  }
                },
                {
                  "typeAttribute": {
                    "name": "attr2",
                    "type": "text",
                    "collation":"en_US"
                  }
                },
                {
                  "typeAttribute": {
                    "name": "Attr3",
                    "type": "real"
                  }
                },
                {
                  "typeAttribute": {
                    "name": "ATTR4",
                    "type": "line"
                  }
                }
              ]
            }
          },
          {
            "renameCompositeTypeAttribute": {
              "typeName": "myType",
              "oldAttributeName": "attr1",
              "newAttributeName": "att®1",
              "onUpdate": "CASCADE"
            }
          },
          {
            "renameCompositeTypeAttribute": {
              "typeName": "myType",
              "oldAttributeName": "attr2",
              "newAttributeName": "attribute 2",
              "onUpdate": "CASCADE"
            }
          },
          {
            "renameCompositeTypeAttribute": {
              "typeName": "myType",
              "oldAttributeName": "Attr3",
              "newAttributeName": "AtTrIbUtE3",
              "onUpdate": "CASCADE"
            }
          },
          {
            "renameCompositeTypeAttribute": {
              "typeName": "myType",
              "oldAttributeName": "ATTR4",
              "newAttributeName": "attr & 4",
              "onUpdate": "CASCADE"
            }
          }
        ]
      }
    }
  ]
}
<?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="attr1" type="int"/>
            <pro:typeAttribute name="attr2" type="text" collation="en_US"/>
            <pro:typeAttribute name="Attr3" type="real"/>
            <pro:typeAttribute name="ATTR4" type="line"/>
        </pro:createCompositeType>
        <pro:renameCompositeTypeAttribute typeName="myType" oldAttributeName="attr1" newAttributeName="att®1" onUpdate="CASCADE"/>
        <pro:renameCompositeTypeAttribute typeName="myType" oldAttributeName="attr2" newAttributeName="attribute 2" onUpdate="CASCADE"/>
        <pro:renameCompositeTypeAttribute typeName="myType" oldAttributeName="Attr3" newAttributeName="AtTrIbUtE3" onUpdate="CASCADE"/>
        <pro:renameCompositeTypeAttribute typeName="myType" oldAttributeName="ATTR4" newAttributeName="attr &amp; 4" onUpdate="CASCADE"/>
    </changeSet>
</databaseChangeLog>

Database Support

This change type is only supported for PostgreSQL.