createCompositeType

The createCompositeType defines a custom data structure that can be used in PostgreSQL tables, columns, and function signatures to organize related fields into a single logical structure.

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

Run createCompositeType

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 where you want to create a new type Optional
typeName String Name of the type you want to create Required

Nested tags

typeAttribute String Individual fields inside of the composite type. 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: "text"
                  collation: "en_US"
              - typeAttribute:
                  name: "att®3"
                  type: "line"
              - typeAttribute:
                  name: "attribute 4"
                  type: "real"

{
  "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": "text",
                    "collation":"en_US"
                  }
                },
                {
                  "typeAttribute": {
                    "name": "att®3",
                    "type": "line"
                  }
                },
                {
                  "typeAttribute": {
                    "name": "attribute 4",
                    "type": "real"
                  }
                }
              ]
            }
          }
        ]
      }
    }
  ]
}
<?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="text" collation="en_US"/>
            <pro:typeAttribute name="att®3" type="line"/>
            <pro:typeAttribute name="attribute 4" type="real"/>
        </pro:createCompositeType>
    </changeSet>
</databaseChangeLog>

Database Support

This change type is only supported for PostgreSQL.