alterCompositeTypeAttributes
The alterCompositeTypeAttributes change type allows you to change the attributes that are associated with a composite type. You can add, alter, or drop composite type attributes.
Note: Inspection features or commands, such as snapshot
, diff
, generate-changelog
, and diff-changelog
, are not currently supported with composite types.
Run alterCompositeTypeAttributes
To run this Change Type, follow these steps:
- Add the Change Type to your changeset, as shown in the examples on this page.
- Specify any required attributes. Use the table on this page to see which ones your database requires.
- Deploy your changeset by running the
update
command:
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 alter | Required |
typeName
|
String | Name of the type you want to alter | Optional |
Nested tags
Name | Type | Description | Requirement |
---|---|---|---|
addAttribute | String | Add an attribute to a composite type. This is an object that can be passed name , type , collation , and onCreate parameters. |
You must choose to use addAttribute , alterAttribute , or dropAttribute . |
alterAttribute | String | Change an object associated with a composite type. This is an object that can be passed name , type , collation , and onUpdate() . |
You must choose to use addAttribute , alterAttribute , or dropAttribute . |
dropAttribute | String | Remove an attribute associated with a composite type. This is an object that can be passed name , ifExists , and onDelete() . |
You must choose to use addAttribute , alterAttribute , or dropAttribute . |
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"
alterAttributes:
- alterAttribute:
name: "attr0"
newType: "text"
collation: "en_US"
onUpdate: "RESTRICT"
dropAttributes:
- dropAttribute:
name: "attr1"
ifExists: "true"
onDelete: "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"
}
}
],
"alterAttributes": [
{
"alterAttribute": {
"name": "attr0",
"newType": "text",
"collation": "en_US",
"onUpdate": "RESTRICT"
}
}
],
"dropAttributes": [
{
"dropAttribute": {
"name": "attr1",
"ifExists": "true",
"onDelete": "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:alterAttribute name="attr0" newType="text" collation="en_US" onUpdate="RESTRICT"/>
<pro:dropAttribute name="attr1" ifExists="true" onDelete="CASCADE"/>
</pro:alterCompositeTypeAttributes>
<rollback/>
</changeSet>
</databaseChangeLog>
Database Support
This change type is only supported for PostgreSQL.